Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

sum based on two dates

= sum({<Date={">=$(vStartDate)"}*{"<=$(vEndDate)"}>} Actuals)


The above equation shows the correct value when i click on each and every product. But when I click on Brand wise, it is not providing the correct value. The date range is not working if i click on two products at the same time.


Am I missing any aggregation for date? Any suggestions will be appreciated.

25 Replies
sunny_talwar

How do you define vStartDate and vEndDate?

hic
Former Employee
Former Employee

How are the variables defined? How are Products linked to Date and Actuals?

You need to post an example app.

HIC

Not applicable
Author

vStartDate = Date(aggr(Date_of_Product),product_key)

vEndDate=Addmonths(vstartDate,2)


Anonymous
Not applicable
Author

I guess that your two products have different startdates

can you check for each product what startdate is displayed (create textobject with vStartdate)

Clever_Anjos
Employee
Employee

You need an aggregation inside your AGGR() function

Max()? Min()?

Date(aggr( here  Date_of_Product),product_key)

Not applicable
Author

Yes you are right the two products having different startdates so in that case, how I'm able to get the sum of Actuals of two products. Any idea.

Not applicable
Author

First I used min (startdate) and I can achieve the correct results. But the requirement is like different dates for every product.

For a particular brand I have different products with different dates. So for overall - how I can achieve the result?

Anonymous
Not applicable
Author

use min or max

= sum({<Date={">=min($(vStartDate))"}*{"<=max($(vEndDate))"}>} Actuals)

not sure if Syntax is correct

Clever_Anjos
Employee
Employee

As hic‌ techs us in https://community.qlik.com/blogs/qlikviewdesignblog/2015/10/05/pitfalls-of-the-aggr-function

1. Missing inner aggregation function

The first parameter of the Aggr() is a measure, and as such it is always an aggregation. Hence, you should use an aggregation function. If you don’t, the calculation will use Only() and the virtual table may inadvertently get NULLs in the Measure column. See more on Use Aggregation Functions!