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

Announcements
Talend Cloud AWS EU Scheduled Outage: Starting Tues 26 May 21:00 CEST with expected completion Wed 27 May 01:00 CEST
cancel
Showing results for 
Search instead for 
Did you mean: 
chaorenzhu
Creator II
Creator II

Use max value regardless of other field

Hi experts,

To simply, let's say we use such data

load * inline [
year, category, number
2021,A,20
2020,A,30
2020,B,40
];

In filter pane I use 2 dimensions, year and category. Now I create a KPI with the expression of 

If(getselectedcount(year)=0, sum({<year={"$(=max(year))"}>} number) ,sum(number))

to get the sum of number, with default value as the max of year.

However, when the user selects category as 'B' in the filter pane, because there's no record of category B in 2021, this expression will return 40. The user wants to show 0 instead, as the default year is expected to be the latest year (2021 in this case). 

Can you advise how to achieve it? Thank you!

1 Solution

Accepted Solutions
Vegar
MVP
MVP

You can add a set into your max() modifier like this.

If(getselectedcount(year)=0, sum({<year={"$(=max({1}year))"}>} number) ,sum(number))

View solution in original post

2 Replies
Vegar
MVP
MVP

You can add a set into your max() modifier like this.

If(getselectedcount(year)=0, sum({<year={"$(=max({1}year))"}>} number) ,sum(number))

chaorenzhu
Creator II
Creator II
Author

Thanks Vegar, I should've thought of that