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: 
Not applicable

Set analysis to get max Month per year in a chart.

How can I do this in set analysis? I want to get the latest month per year.

 

YearMax(Month)AmountComment
201512$100.00Amount for Dec 2015
20167$200.00Amount for July 2015
2017-$0.00

If I use this expression the max month is always 12.


SUM({< Month= {"$(=max({Month))"}>}  Amount)


Result.


YearMax(Month)Amount
201512$100.00
201670
2017-0



expected result should be this.


YearMax(Month)Amount
201512$100.00
20167$200.00
2017-$0.00


1 Solution

Accepted Solutions
tresesco
MVP
MVP

Try:

FirstSortedValue(Aggr(Sum(Outstanding),Year,Month), -Aggr(Month, Year, Month))

Untitled.png

Please be careful of marking the 'correct answer' the right one, so that other people searching for similar solution is not misdirected.

View solution in original post

15 Replies
Chanty4u
MVP
MVP

try

Firstsortedvalue(Month,-Amount)

or

Firstsortedvalue(Amount,-Month)

tresesco
MVP
MVP

Set analysis would not work here since it doesn't evaluate row-wise but once for a chart.

Try like:

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

Not applicable
Author

I tried getting the sum. but it's returning null. Not sure why it does not work in my data, 

Not applicable
Author

i have multiple rows Amount with month = Max month.  Looks like this only works with one row as max Month. 

NZFei
Partner - Specialist
Partner - Specialist

Check this out.

Dimension: Year, Month

Expression: if(Month=max(total <Year> Month),1,0)*sum(Sales)

Fei

Not applicable
Author

Dude you're the best! high 5!

Not applicable
Author

I tried now showing the Month field but it does not work. do you have other solution for this?

tresesco
MVP
MVP

If you have multiple rows of Amount against max month, what do you want to do with them? Should they be summed up? If yes, my proposed solution above works that way. If the Amount values are just repeat (same) you can simply use Distinct like:

FirstSortedValue(Distinct Amount, -Month)


If possible, post a sample qvw.

NZFei
Partner - Specialist
Partner - Specialist

What is the problem now?

I have added some more lines and it is still working for me.