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
Antoine04
Partner - Creator III
Partner - Creator III

Hello

Try something like this in your set analysis for YTD : Date = {" <= $(=Date(AddYears(Max(Date),-1))) "}

It should work.

I can try with you data if you can send me the qvf and I can send it back to you

Regards

Antoine L

s4ni9r
Contributor III
Contributor III
Author

expression is throwing error

Aditya_Chitale
Specialist
Specialist

@s4ni9r ,

You will need to create a bridge between the button and your expression using variable, You can try setting variable values on button press and check variable value in expression to activate either MTD or YTD expressions.

If you are using default qliksense button, you can find 'Set Variable Value' option under add action.

Regards,

Aditya

s4ni9r
Contributor III
Contributor III
Author

i need the expression for MTD and YTD variables

Antoine04
Partner - Creator III
Partner - Creator III

Can you please share an example of your data ?

Thanks

Aditya_Chitale
Specialist
Specialist

Can you share sample data so that I can get an idea of the data format ?

Regards,

Aditya

s4ni9r
Contributor III
Contributor III
Author

i have date column in the filter which shows date from 1,2,3,4,5,6 and month column as filter which shows values Jan, Feb, March.. and year column as Filer which shows values 2021,2022,2023..

Now my requirement is to have a MTD and YTD button, if i click on the MTD button the data which is in a pivot table should be filtered for MTD.

if i click YTD button, the data in the pivot table should be filterd for YTD.

pravinboniface
Creator II
Creator II

Assuming that
- you have a date column date_col
- you use day(date_col), month(date_col), and year(date_col) as the fields for the filter

Then you may be able to use expressions as follows based on your MTD/YTD variable

MTD
sum({1<date_col= {"<=$(=date_col)>=$(=MonthStart(date_col))"}> } sales)

YTD
sum({1<date_col= {"<=$(=date_col)>=$(=YearStart(date_col))"}> } sales)

s4ni9r
Contributor III
Contributor III
Author

I would need the expression to be written in the MTD button, not on the chart