Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
garyvary123
Contributor III
Contributor III

Variable input to select dates

Hey guys, I'm new to Qlik and trying to make a variable button. I want to make past 7 days, MTD, QTD, YTD buttons.

I created a variable vDates how can I make an expression that controls the dates for my variable ReportingDate?

I know that for MTD I'll have to do something like MonthStart(Max(ReportingDate)) and something similar for QTD and YTD but I'm not sure how to get the range since this just gives me 1 value. Any help will be appreciated.

4 Replies
abhijitnalekar
Specialist II
Specialist II

Hi @garyvary123,

Please go through with the below link

https://community.qlik.com/t5/QlikView-Documents/Date-Level-Analysis-WTD-MTD-QTD-YTD-Current-Year-Pr... 

Regards,
Abhijit
keep Qliking...
Help users find answers! Don't forget to mark a solution that worked for you!
AshutoshBhumkar
Partner - Specialist
Partner - Specialist

Hello,

1. Let your buttons store values in one variable (vVar). Like, Past 7 Days button will store 1 in vVar, MTD button will store 2, QTD will store 3 and YTD will store 4.

2. Now check if vVar is getting values as per the button selection.

3. Use Pick(), Match() function to pick measures as per the button selection.

 

E.g

Pick( vVar,

Sum({<Set for past 7 days>}Sales),

Sum({<Set for MTD>}Sales),

Sum({<Set for QTD>}Sales)

Sum({<Set for YTD>}Sales)

)

Thanks,

Ashutosh

garyvary123
Contributor III
Contributor III
Author

Hey Ashutosh, thanks for this but I'm not looking for the Sum of some variables. A specific example of what I'm trying to do is convert a button that I've already made into a variable input so it looks prettier. For example:

I have a button with Action: Select values matching search criteria

Field: ReportingDate

Expression: ='>$(=YearStart(Max([ReportingDate])))<=$(=Max([ReportingDate]))

When I press this button it shows only YTD values which is perfect. I want to convert this into a variable input button so that it doesn't look as sloppy. 

garyvary123
Contributor III
Contributor III
Author

Hey Abhijit, I'm not looking for a sum of variables or something along those lines. I just want to select values matching a search criteria using variable input. Please see my reply to Ashutosh. Thanks