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: 
dmac1971
Creator III
Creator III

Max Month Expression based on Selection

I have the following expression in a gauge chart that works perfectly when no Month selection is made :

=count({<
MonthNumber ={"$(=max(MonthNumber))"},
Daily_Working_Hours = {">0"},
Total_Working_Hours = {">20"}
>}DISTINCT SERIAL#)

/

Count({<
Measure = {'InitialDate'},
Total_Working_Hours = {">20"}
>}Distinct SERIAL#)

However when any month is selected other than the initial month the expression breaks and returns the wrong answer.  I cant figure out where its falling over.

Maybe expression should consider the range of months available?  IE MonthNo >min(MonthNo) < Max(MonthNo)?

Labels (1)
3 Replies
sunny_talwar

What exactly do you mean when you say wrong result? Would you be able to share a sample where we can see the issue?

Vegar
MVP
MVP

You will need to explain what's not working as expected.

A tip is to temporary break your expression in two to check which part is returning the wrong figures.

Your current first part of your expression is calculating of the latest month in your selection. So if you select a month then this will be reflected in your expression as well. If you select multiple months then it will only calculate for the latest in that section. 

dmac1971
Creator III
Creator III
Author

Thanks for replies both.  So with no month selected the chart resolves to show result for Sep and this is correct.  If I isolate a single month the result will be incorrect, say I select Jul-2020 I get this error, however selecting Jan-2019 through to Jul-2020 I then get the correct result. 

I'm trying to have the chart display the maximum month selected, and if no selection made then current month.