Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
s4ni9r
Contributor III
Contributor III

MTD YTD Button

Hi All,

I need two buttons for MTD and YTD in Qliksense, if i select MTD the data in the dashboard should be filtered for MTD. if i select YTD, the data should be filtered for YTD.

Could you please help me with the expressions for YTD and MTD.

 

Thanks in Advance.

Labels (4)
15 Replies
s4ni9r
Contributor III
Contributor III
Author

 i mean the logic which has to be written on the MTD button

Antoine04
Partner - Creator III
Partner - Creator III

OK, I get it, so maybe like this ?

Pic 1 : by clicking on YTD :

Antoine04_0-1708075616013.png

Pic 2 : by clicking on MTD :

Antoine04_1-1708075636053.png

 

If yes, then you need this in your button formulas :

YTD : ='>=$(=YearStart(Max(Date)))<=$(=Max(Date))'

MTD : ='>=$(=MonthStart(Max(Date)))<=$(=Max(Date))'

With action : Select values matching criteria

 

Best regards,

Antoine L

s4ni9r
Contributor III
Contributor III
Author

Hi Sir,

Thanks a million for your help Sir, the MTD logic that you gave is filtering 1 to 16, but what i would need is 

if i click MTD button, it should filter for Feb 1 to Feb 16 2024.

s4ni9r
Contributor III
Contributor III
Author

Could you please help me sir

Antoine04
Partner - Creator III
Partner - Creator III

Antoine04_0-1708089729558.png

Yes, that is exactly what I've done, as you can see in the table below the button

 

pravinboniface
Creator II
Creator II

The button would just set a variable, no?

You can define a variable called vMtdYtd and initialize in your load script

SET vMtdYtd='<=$(=date_col)>=$(=MonthStart(date_col))'  // Initialized for MTD

In the MTD button, you would set the variable to 

'<=$(=date_col)>=$(=MonthStart(date_col))'

In the YTD button, you would set the variable to 

'<=$(=date_col)>=$(=YearStart(date_col))'

Your pivot table expressions would look like:

sum({1<date_col= {'$(vMtdYtd)'}> } sales)