Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
tm_burgers
Creator III
Creator III

Get Date where Sum(Sales) is Max

I am trying to highlight the date where the sum(sales) was the maximum.

 

The Set Analysis I am using for Sales is ;

Sum({<[ReportDate.autoCalendar.MonthsAgo]={"<14"}>} Sales)

 

To get the Max value :

MAX(AGGR(Sum({<[ReportDate.autoCalendar.MonthsAgo]={"<14"}>} Sales),ReportDate.autoCalendar.MonthsAgo]))

 

This results in the correct max sales value - But, I would like to return the Date that the max value occurred, and not the value itself.

1 Solution

Accepted Solutions
anat
Master
Master

can u try using FirstSortedValue :

FirstSortedValue(Month, -Aggr(Sum(Sales), Month))

or 

=only({<sales={'$(=Max(sales))'}>}Month)

View solution in original post

2 Replies
albertovarela
Partner - Specialist
Partner - Specialist

Give this a try: only({$<[ReportDate.autoCalendar.MonthsAgo]={"=(Rank(AGGR(Sum({$<[ReportDate.autoCalendar.MonthsAgo]={'<14'}>}Sales),[ReportDate.autoCalendar.MonthsAgo])))=1"}>}[ReportDate.autoCalendar.Month)

anat
Master
Master

can u try using FirstSortedValue :

FirstSortedValue(Month, -Aggr(Sum(Sales), Month))

or 

=only({<sales={'$(=Max(sales))'}>}Month)