Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
TheBeginner
Contributor II
Contributor II

Creating a button to select Past one month

Hi Everyone,

I'm trying to create a button for selecting last past one month data.

For this i have created a button and added two actions to Set Variable where one variable name is vStartDate and other one is vEndDate for vStartDate i have given a value as =Monthstart(Max({1}[Activity Creation Date]),-1) and for vEndDate  =MonthEnd(Max({1}[Activity Creation Date]),-1) this is working fine.

Like  changing the vStartDate and vEndDate to past one month dates.

Now, I want on clicking this button it has to apply filter can any one help me with the Select field action The Field i'm using is Activity Creation Date.

 

Thanks Inadvance.

1 Solution

Accepted Solutions
jwjackso
Specialist III
Specialist III

='>='&Date(MonthStart(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY')&'<='&Date(MonthEnd(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY')

View solution in original post

10 Replies
jwjackso
Specialist III
Specialist III

If you want to set the [Activity Creation Date] for all visualization in the application, it would be easier to use the "Select In Field" action of the button.  The field will be [Activity Creation Date] and the "Search String" will be 

='('&Chr(34)&Concat({<[Activity Creation Date]={">=$(=MonthStart(Max({1}[Activity Creation Date]),-1))<=$(=MonthEnd(Max({1}[Activity Creation Date]),-1))"}>}[Activity Creation Date],Chr(34)&'|'&Chr(34))&Chr(34)&')'

 

The "Search String" is going to look like '("7/1/2020"|"7/2/2020"|....|"7/31/2020")'

The pipe symbol is a logical  "OR" operator

 

If you use the button to set 2 variables, you will need to use Set Analysis and  add the variable to each calculation.

TheBeginner
Contributor II
Contributor II
Author

Hi @jwjackso ,

Firstly thanks for reply,

Actually it is not working my date format is 'DD-MMM-YYYY' could you please help me out.

Thanks In advance

jwjackso
Specialist III
Specialist III

Add a Date function to format the date field correctly

='('&Chr(34)&Concat({<[Activity Creation Date]={">=$(=Date(MonthStart(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY'))<=$(=Date(MonthEnd(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY'))"}>}[Activity Creation Date],Chr(34)&'|'&Chr(34))&Chr(34)&')'

TheBeginner
Contributor II
Contributor II
Author

@jwjackso Thank you so much it is working, But in current selections showing like this 

satyatechnologies_0-1598458267644.png

But i want to show the range instead like 

satyatechnologies_1-1598458334208.png

 

Could you please help me out.

 

Thanks in advance

jwjackso
Specialist III
Specialist III

Add a "Distinct" to display the dates only once.  I'll see if it is possible to format the date they you want.

='('&Chr(34)&Concat({<[Activity Creation Date]={">=$(=Date(MonthStart(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY'))<=$(=Date(MonthEnd(Max({1} [Activity Creation Date]),-1),'DD-MMM-YYYY'))"}>} Distinct [Activity Creation Date],Chr(34)&'|'&Chr(34))&Chr(34)&')'

TheBeginner
Contributor II
Contributor II
Author

Again Thanks @jwjackso I worked.

It is showing distinct values

satyatechnologies_0-1598459650701.png

 

But my requirement is to show like 

satyatechnologies_1-1598459716178.png

 

Could you please help me out

Thanks in advance

jwjackso
Specialist III
Specialist III

This "Search String" looks like the format you want:

='(>='&Date(MonthStart(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY')&'<='&Date(MonthEnd(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY')&')'

TheBeginner
Contributor II
Contributor II
Author

@jwjackso Thank you so much. Finally it worked but last one thing is there any possibilities to remove brackets ()

I mean currently it was like this 

satyatechnologies_0-1598460491967.png

Can we have it like

satyatechnologies_1-1598460520182.png

 

Thanks in advance

jwjackso
Specialist III
Specialist III

='>='&Date(MonthStart(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY')&'<='&Date(MonthEnd(Max({1}[Activity Creation Date]),-1),'DD-MMM-YYYY')