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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
agilos_mla
Partner - Creator III
Partner - Creator III

Set analysis returns unexpected results

Hi guys, I need your help on this interesting case. I've got this data set :



YearDateAmount
200931/12/2009912
201030/06/20101006
201030/09/20101009
201131/01/20111101
201128/02/20111102


I would like to get into a pivot chart , the year, the max date founded for each year and the value related to this max date, whatever the selection. It will look like :

YearMax({1}Date)Expression
200931/12/2009912
201030/09/20101009
201128/02/2011

1102

I encounters some issues to resolve the Expression . I tried :

sum( {1<Date={'$(=Date(Max(Date)))'}>} Amount)

it returns the right value for year 2011 but 0 for previous years. What is missing in this set analysis to obtain the desired results or another way to solve the problem without getting back bo the script?

Thx,

Michael

1 Solution

Accepted Solutions
Not applicable

Hi Michael, try this:

For the max date -> date(max(Date)

For the value associated -> firstsortedvalue(Amount,-Date)

Set analysis is not going to work in this case, since it is evaluated once per chart and not for every value within the domension.

Regards

View solution in original post

4 Replies
Not applicable

Hi Michael, try this:

For the max date -> date(max(Date)

For the value associated -> firstsortedvalue(Amount,-Date)

Set analysis is not going to work in this case, since it is evaluated once per chart and not for every value within the domension.

Regards

johnw
Champion III
Champion III

Ivan's solution should work if you don't actually need a sum, though you'll probably want to add a {1} to it if I understood your question.

If you DO need the sum, maybe this?

sum({1<Date={'$(=concat({1} aggr(max({1} Date),Year),chr(39) & ',' & chr(39)))'}>} Amount)

Yes, set analysis is only evaluated once per chart, but with the expression above (if I got it right), we generate a list of all the dates of interest. Only ONE of those dates will match each line in your chart, so everything will come out as expected in the end.

Not applicable

Yes John is right, in case you need the sum of amount's that will be the expression to use, although I think there is missing a date conversion for the expression to work properly, like this:

sum({1<Date={'$(=concat({1} aggr(date(max({1} Date)),Year),chr(39) & ',' & chr(39)))'}>} Amount)

Regards

agilos_mla
Partner - Creator III
Partner - Creator III
Author

Both Solutions works great !

I'm going to use the one with the sum since I get just a sample of the data, there might be multiple value ifor the Mac Date that must be summed probably in this case.

Thx guys,

Michael