Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
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
Not applicable
Author

try below:

vStartDate = Date(min(aggr(min(Date_of_Product),product_key)))

Anonymous
Not applicable
Author

I guess you Need min max in variable

vStartDate = min(Date(aggr(Date_of_Product),product_key))

vEndDate=Addmonths(vstartDate,2)

then you can Keep the expression

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

Not applicable
Author

The requirement is like different date for different product so I have removed the min from the variable. Now I can get the value for every product but when i click on Brand it is not giving the proper summation. Date difference is not working perfectly.

So where I have to use the aggregation exactly to resolve the issue. I have tried aggr() but its not working. Is there any solution for this issue?

Clever_Anjos
Employee
Employee

A solution would be using AGGR as designed, with a inner aggregation function.

Please describe what vStartDate should return

Not applicable
Author

vStartDate should return the date_of_product which differs for each product

Clever_Anjos
Employee
Employee

But what if you have "two products at the same time"? Which date should be returned?

Clever_Anjos
Employee
Employee

Remember that a variable (like a function) in general returns an atomic value (only one)

Not applicable
Author

yes.. But this is what the requirement. So I couldn't find the solution. seeking the help of experts. Is there any way to achieve this ?

Clever_Anjos
Employee
Employee

But what if you have "two products at the same time"? Which date should be returned?

jyothish8807
Master II
Master II

Hi Vinu,

Your variable will not return the correct value:

Try like this:

vStartDate = Date(aggr(min(Date_of_Product),product_key)

vEndDate=Addmonths(vstartDate,2)


exp:

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


Regards

KC

Best Regards,
KC