Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
brf10043
Creator
Creator

Default to Latest Month

All,

I have a table where I am trying attempting to get the table to default to the lasted month's data.  Then, when the user selects other months the table refreshes and list the data for the selected months.

I have it somewhat close.  I have variable vCurrentMonth defined as "$(=MonthName(AddMonths(max(MonthName),0)))"  and use expressions like Only({<MonthName = {$(vCurrentMonth)}>}Vulnerability).

This does default the table to the latest data month as it uses max(Month) in the variable.  However, because the variable uses max(Month) in the variable when multiple months are selected the table will always only display the latest month from the months selected. 

Do you have any suggestions that would default the table to only display the data for the latest month in the data and when the user selects multiple months display the data for all months selected?

Thanks

1 Solution

Accepted Solutions
sunny_talwar

Notice that if a selection is made in Month field, then the expression that will be used doesn't have any set analysis:

If(GetSelectedCount(Month) = 0, Only({<MonthName = {$(vCurrentMonth)}>}Vulnerability), Only(Vulnerability))

Are you sure this isn't working? May be you need another aggregation function like Avg or Sum?

If(GetSelectedCount(Month) = 0, Only({<MonthName = {$(vCurrentMonth)}>}Vulnerability), Sum(Vulnerability))

View solution in original post

4 Replies
sunny_talwar

Try this may be:

If(GetSelectedCount(Month) = 0, Only({<MonthName = {$(vCurrentMonth)}>}Vulnerability), Only(Vulnerability))

brf10043
Creator
Creator
Author

Thanks Sunny, but I'm getting the same result  I believe it's because vCurrentMonth is defined as "$(=MonthName(AddMonths(max(MonthName),0)))"

because of the max the variable will only ever display the latest month.

sunny_talwar

Notice that if a selection is made in Month field, then the expression that will be used doesn't have any set analysis:

If(GetSelectedCount(Month) = 0, Only({<MonthName = {$(vCurrentMonth)}>}Vulnerability), Only(Vulnerability))

Are you sure this isn't working? May be you need another aggregation function like Avg or Sum?

If(GetSelectedCount(Month) = 0, Only({<MonthName = {$(vCurrentMonth)}>}Vulnerability), Sum(Vulnerability))

brf10043
Creator
Creator
Author

Apologies Sunny, your code does in fact accomplish the goal.  Turns out I had an issue with one of the lists boxes which was impacting the table.

Thanks once again!