Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
aaronnayan
Creator III
Creator III

Sales for the largest month expression

Hi Guys

I want to create a variable,

Is there a way for me to calculate the month with the largest sales

Mont field is "DEC_Month"

Sales field is "SALES"

N.B .  It should only show one month

16 Replies
Anil_Babu_Samineni

This?

FirstSortedValue(DEC_Month, -Max(SALES))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
aaronnayan
Creator III
Creator III
Author

No sorry anil that doesnt work

Anil_Babu_Samineni

My Bad, Should work

FirstSortedValue(DEC_Month, -Aggr(Max(SALES), DEC_Month))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
tresesco
MVP
MVP

Try like:

FirstSortedValue(DEC_Month, -Aggr(Max(SALES),DEC_Month))

aaronnayan
Creator III
Creator III
Author

Hi Anil

If i was to save your expression

I would create a variable  

FirstSortedValue(DEC_Month, -Max(SALES))>>>  vTopMonth

Then in my chart i would use this

Sum({1<DEC_Month={'$(vTopMonth)'}>}SALES)

If you see errors please tell me

Kind Regards

Anil_Babu_Samineni

Use this in variable

FirstSortedValue(DEC_Month, -Aggr(Max(SALES), DEC_Month))

Then, Set analysis should be this?

Sum({1<DEC_Month = {"$(=$(vTopMonth))"}>} SALES)

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
aaronnayan
Creator III
Creator III
Author

Very Very close its giving a result,

but its not selecting the largest month 😮

Its selecting the middle month if that helps

I have 3 months and its selecting the middle one, not the lowest or the highest.

Could it be the varible?

tresesco
MVP
MVP

You could even directly try like:

Sum({1<DEC_Month={"=DEC_Month=Max(total SALES)"}>}SALES)

Anil_Babu_Samineni

Check testing in text object and tell me whether you are getting any thing or not?


=vTopMonth

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful