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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
hov
Contributor II
Contributor II

nested set analysis

Hi, I am new to qlik and am having some trouble with a set analysis expression im trying to handle.

I am trying to calculate the diff of a measure between the max date in the selection and its predecessor. 

date_num = integer value of my date, increasing

report name = report selection 

A region filter also applies 

I would like something as follows however this doesnt work when a single date is selected. 

count({<date_num={$(=max(date_num))}>}ReportName) - count({<date_num={$(=max(date_num, 2))}>}ReportName)

I would like to keep the other two filters to work as normal (reportname and region)

Labels (3)
12 Replies
agigliotti
MVP
MVP

maybe this:

=date( max( {< date_num = E( date_num ) * {"<$(=Max(date_num))"} >} date_num ) )

it should works when a single date has been selected giving you the same value as Max(date_num,2).

I hope it can helps.

Best Regards

The Power of shining a light on the dark side of your data.
Follow me on my LinkedIn | Know Gamma Informatica at gammainformatica.it
marcus_sommer
MVP
MVP

No, it won't produce the same issue because it overwrites the set selection. Therefore, the following should work:

count({<date_num={$(=max(date_num))}>}ReportName) -
count({<date_num={$(=max(date_num)-1)},
   ReportName=p(ReportName), Region=p(Region)>}ReportName)

in regard to the above mentioned fact of the existing date_num.

- Marcus

hov
Contributor II
Contributor II
Author

Hi thank you for your input.

This approach worked for me, with the addition of {1} in the subtraction.

count({<date_num={$(=max(date_num))}>}ReportName) - count({1<date_num={$(=max(date_num)-2)}, ReportName=p(ReportName), Region=p(Region)>}ReportName)