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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources 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!

1 Solution

Accepted Solutions
sunny_talwar

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

May be this

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

sunny_talwar

This should show the count for the Max New_Reporting_Period

Kushal_Chawda

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

This

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

sunny_talwar

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

May be this

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