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: 
dranjbar
Contributor III
Contributor III

Creating a drop down for Dates ranges

Hi All,

 

Just trying to create a drop down where I can select a few different date ranges such as last 7 days, last 14 days etc.

Currently I can create a button and set the Field to "Date" and set the value to 

='<' & Date(Today()) & '>=' & Date(Today()- 7)

dranjbar_0-1614122939575.png

which will select me the last 7 days from todays date. Although I want to somehow convert this into some type of drop down where i can have a few different selections to pick from.

Im trying to now use the Variable extension where I can set fixed values (of the same code I had before) which looks like this, but once I switch from one selection to another, the date doesn't get selected. 

dranjbar_1-1614123093868.png

I do have to select/create a variable which I have just created an empty one called "zdate" that doesnt contain anything inside which might be where I am going wrong as I'm not quite sure what to put in here to make it work. 

dranjbar_2-1614123118829.png

 

Is anyone able to help me with this or let me know an alternative option?

I've had a look as the developer extensions users have created although there isn't anywhere I can customize the dates I want to show.

 

Thanks

 

 

 

 

Labels (1)
1 Reply
Saravanan_Desingh

You can create Rules like this:

CalRules:
LOAD * INLINE [
    Name, Rule1, Rule2
    Today, =Today()
    Yesterday, "=Today()-1"
    Last 7 Days, ">=Today()-7"
    Last 10 Days, ">=Today()-10"
    Last 14 Days, ">=Today()-14"
    Last 30 Days, ">=Today()-30"
    This Week, ">=WeekStart(Today())"
    Last Week, ">=WeekStart(Today(),-1)", "<=WeekEnd(Today(),-1)"
    Last Two Weeks, ">=WeekStart(Today(),-2)", "<=WeekEnd(Today(),-2)"    
    This Month, ">=MonthStart(Today())"
    Last Month, ">=MonthStart(Today(),-1)", "<=MonthEnd(Today(),-1)"
    Last Two Months, ">=MonthStart(Today(),-2)", "<=MonthEnd(Today(),-2)"    
    This Year, ">=YearStart(Today())"
    Last Year, ">=YearStart(Today(),-1)", "<=YearEnd(Today(),-1)"
];

tab1:
LOAD Date(Today()-IterNo()+1) As tranDate
AutoGenerate 1
While IterNo() <=135
;
Left Join(tab1)
LOAD *
Resident CalRules;

tab2:
LOAD *, Evaluate(Chr(39)&tranDate&Chr(39)&Rule1&If(Not IsNull(Rule2),' And '&Chr(39)&tranDate&Chr(39)&Rule2)) As Eval, 
	Chr(39)&tranDate&Chr(39)&Rule1&If(Not IsNull(Rule2),' And '&Chr(39)&tranDate&Chr(39)&Rule2) As Str
Resident tab1;

tab3:
NoConcatenate
LOAD *
Resident tab2
Where Eval;

Drop Table CalRules, tab1, tab2;