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: 
kevbrown
Creator II
Creator II

Sum Max

I have the following expression and I want to only see the Max New_Reporting_Period but for some reason I can't get my head round it

=count(distinct If(DaysToTS_Acc<21,Risk_No))

I'm sure it's simple!

Labels (1)
1 Solution

Accepted Solutions
sunny_talwar
MVP
MVP

Actually these might also work:

Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"$(=Max(New_Reporting_Period))"}>} Risk_No)

2nd Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"$(=Max(New_Reporting_Period, 2))"}>} Risk_No)

View solution in original post

10 Replies
sunny_talwar
MVP
MVP

May be this

FirstSortedValue(Aggr(Count(DISTINCT {<DaysToTS_Acc = {'<21'}>} Risk_No), New_Reporting_Period), -New_Reporting_Period)

sunny_talwar
MVP
MVP

This should show the count for the Max New_Reporting_Period

Kushal_Chawda
MVP
MVP

What is the format of New_Reporting_Period  field?

kevbrown
Creator II
Creator II
Author

Awesome, thanks Sunny, and to do the previous month?

sunny_talwar
MVP
MVP

This

FirstSortedValue(Aggr(Count(DISTINCT {<DaysToTS_Acc = {'<21'}>} Risk_No), New_Reporting_Period), -New_Reporting_Period, 2)

sunny_talwar
MVP
MVP

Actually these might also work:

Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"$(=Max(New_Reporting_Period))"}>} Risk_No)

2nd Max

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"$(=Max(New_Reporting_Period, 2))"}>} Risk_No)

kevbrown
Creator II
Creator II
Author

Yes, these worked perfectly. Thank you

kevbrown
Creator II
Creator II
Author

Last question on this, can this be adapted to be a rolling 3 month? so included the Max 3 months?

sunny_talwar
MVP
MVP

May be this

Count(DISTINCT {<DaysToTS_Acc = {'<21'}, New_Reporting_Period = {"$(='>=' & Max(New_Reporting_Period, 3) & '<=' & Max(New_Reporting_Period))"}>} Risk_No)