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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Default in Set analysis

Hi,

I have a Requirement to create a report

- which will have defaulted to max year on opening the document

( Achieved it using triggers on open)

- A report which compares current year to previous year comparision of counts

( Achieved it using set analysis for Current year as - =Sum({Year={$(=GetFieldSelections(Year))}>} issuecount)

and year ago counts using =Sum({Year={$(=GetFieldSelections(Year)-1)}>} issuecount)

)

But when we clear the selections the chart dispalys nothing.

my requirement here is to default the graph to max year when all the selections are cleared.

Please can you help

Thanks

KS

1 Solution

Accepted Solutions
simenkg
Specialist
Specialist

Sum({Year={$(=max(Year))}>} issuecount)


Sum({Year={$(=max(Year)-1)}>} issuecount)

View solution in original post

8 Replies
tresesco
MVP
MVP

Try like:

Sum({<Year={$(=Max(Year))}>} issuecount)

and

Sum({<Year={$(=Max(Year)-1)}>} issuecount)

simenkg
Specialist
Specialist

Sum({Year={$(=max(Year))}>} issuecount)


Sum({Year={$(=max(Year)-1)}>} issuecount)

maxgro
MVP
MVP

try with

sum({$<Year={$(=max(Year))}>} issuecount)

Not applicable
Author

Thanks Tresesco for quik help.

I tried it and it worked. I would like to understand its behaviour though.

so when we open the dashboard it takes max year displayes results.

when we select any other year in the list box, is that replacing the max year by the field value selected?

does that mean that qlikview is not checking the expression as is ? if it checks as is, it has to always give the max year as the year available in my entire dataset but it doesnt do that.

please help me with this understanding

Thanks

KS

simenkg
Specialist
Specialist

When no selections are made then all possible values for Year are in the "Year Array".


Selecting a Year/Years will reduce the "Year Array" to those selected values. Selecting another field could also reduce the array because of the associative model.

The Max(Year) function will return the biggest numeric value in the "Year Array".

If you want the function to give you the biggest numeric value in the "Year" field regardless of selections then the expressions becomes:

Max({1} Year). The {1} tells QlikView to disregard user selections.

in expression:

Sum({<Year={$(=Max({1} Year))}> issuecount)

jyothish8807
Master II
Master II

Hi Swapnil,

When ever you select a year QV consider that Year and fetch data corresponding to that year and Year-1.

If you take year as dimension then you can see it will display data for only Max Year and max Year-1 and other years will have 0 corresponding to that.

Regards

KC

Best Regards,
KC
tresesco
MVP
MVP

Max(Year) - returns the max of year out of the years that are in the scope. Now 'in the scope' means -

     - all the years when no year is selected

     - a particular one or multiple years which are selected

So it is actually checking the expression. You have to just understand the 'in the scope' concept. Hope this helps.

Not applicable
Author

Excellent. Thanks for the detailed explanation Simen

Regards

KS