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

Announcements
Join us at Qlik Connect 2026 in Orlando, April 13–15: Register Here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Andrew_ENT
Contributor III
Contributor III

Default to Latest Month in Filter

I Have a filter setup for Year Month. As time passes, new data is created.

The app is set to "Always one selected value" and according to documentation and this youtube video from Qlik Help (Setting a default selected value) the default value should be the one that comes first in the list.

Except that the default value doesn't seem to update as the app does. It uses the value that you had when you published it. Is this as intended or is this a bug? If this is as intended, then how do I go about making the default month always be the current month?

Labels (2)
7 Replies
henrikalmen
Specialist II
Specialist II

That's probably intended. I believe you can solve your issue with a default dynamic bookmark. See this qlik help video: https://help.qlik.com/en-US/video/tFyqOigqnUw 

MatheusC
Specialist II
Specialist II

This is the expected behavior if you want the current Month/Year to always be displayed in the filter and the others not to be visible.

So create the dimension from the expression below, returning only the current field of your data:

=aggr(
if([Year Month]=max(total [Year Month],1),[Year Month]),[Year Month])


- Regards, Matheus

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!
Andrew_ENT
Contributor III
Contributor III
Author

Thanks for the suggestion. That video was interesting and looks really close to giving me an answer.

I tried putting a formula in my filter and I did get results... but the wrong results. My field is YearMonth_ZZZ, because I use ZZZ as a hide suffix. The field YearMonth_ZZZ is created in my script as a dual function using 

DUAL(YearMonth,Monthstart(%Date)) as YearMonth_ZZZ

and YearMonth is defined previously as YEAR&' - '&MONTH

YearMonth_ZZZ=Monthstart(Now()) As per the video I'm explicitly writing out the field name in the filter, no results.

=Monthstart(Now()) Dropping out the field name. I do get results this way, but inexplicably they're wrong.

Because it's a Dual function I should be able to search using the text or the number / date and the fact I'm getting results certainly seems to support this. But the result is just simply to go back to the date it was published which is wrong.

I even checked that Now() Today() and ReloadTime() were all working as expected and they are. See screenshot below.

Andrew_ENT_0-1741942879630.png

 

Andrew_ENT
Contributor III
Contributor III
Author

I don't want it to be part of set analysis. The field is set to "always one selected" so it should always have a value. I just want the default selected month to increment to always show the current month.

 

Thanks for your suggestion though.

henrikalmen
Specialist II
Specialist II

Add an equal sign before your search statement, like this:

=YearMonth_ZZZ=Monthstart(Now())

Do you have a specific reason why you are using dual()? I'm thinking it might be better to keep the value as a date, and then format it as needed in frontend, e.g. date(YearMonth_ZZZ, 'YYYY-MM')

Andrew_ENT
Contributor III
Contributor III
Author

Hi, Yes I was using Dual so that it could be sorted. I think my code just evolved like that for reasons, but I agree using date and specifying the format would be neater, so I've changed that.

Date(Monthstart(DATE),'YYYY - MM') as YearMonth

I tried adding a leading equals sign and still didn't get any results. I expect it's because I'm also using always one selected value? But it's specifically in these instances where we're most likely to want to control what our default "one selected value" is, right?

I tried testing some other ideas. If I take out the YearMonth_ZZZ from the start, then I get this which is bizarre. That's still showing the published date.

Andrew_ENT_0-1741958004221.png

If I ask for Max(YearMonth_ZZZ) then I get the same which is no surprise because that is what is currently selected. But If I ask for Max({1}YearMonth_ZZZ) then I get everything as a list, which it still can't process because it needs 1 selected value. However, this led me down a path of thinking about AGGR.

Andrew_ENT_2-1741958548502.png

 

But no combination that I've tried yet has returned the max date. I've got multiple ways of getting no results and multiple ways of getting the published date.

MatheusC
Specialist II
Specialist II

Ok, so maybe like

"=YearMonth_ZZZ=monthstart( max(total DATE)) "

Did you find a solution to your question? Mark the solution as accepted and if you found it useful, press the like button!