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: 
wenkew186
Creator
Creator

calculate gap between max date and min date in one scope

hi folks,

In my data, there have some date in one week.

I want get the gap between the max date with min date in same week . look the template. it means max date data minus min date data in this week by week dimension. how to write the expression?

12 Replies
uacg0009
Partner - Specialist
Partner - Specialist

Hi Kevin,

Glad to see you, I didn't think that is you.

Well, I think the Tresesco using the AGGR in FirstSortedValue is just for group by the Week,Date when calculating the sum Sales.

So I think if your date is not like

Week1 2016-07-01 10

Week1 2016-07-01 30

Week1 2016-07-02 20


Two same date in one week, so I think you don't need to use the AGGR.


But like you said, your data is more complex, you have many dimensions.

So I think you can try to not use the AGGR, if not correct(I think that's because of the repeat date in dimension), then use AGGR, even though it will make the table a little slow.


Thanks.


Aiolos

vinieme12
Champion III
Champion III


Try below

FirstSortedValue(Aggr(Sum([Secured Amount]), Week,[SNP Process Date]),-Aggr ([SNP Process Date],Week,[SNP Process Date]))
-
FirstSortedValue(Aggr(Sum(
[Secured Amount]), Week,[SNP Process Date]),Aggr ([SNP Process Date],Week,[SNP Process Date]))

Vineeth Pujari
If a post helps to resolve your issue, please accept it as a Solution.
wenkew186
Creator
Creator
Author

Thank you Tresesco!

it works when add 'distinct'. that's really convenient than create in script.

thanks,

Kevin.