Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
mrichman
Creator II
Creator II

How to auto filter calendar for last 7 days or x days?

Hi Qlikview community!

Would be nice if you could help.

I would like to use the trigger function to automatically filter my calendar on the last 7 or x days? The field name of my calendar is Date.

Thanks in advance.

6 Replies
mikaelsc
Specialist
Specialist

cleaner approach? Use a master calendar and use set analysis in your expressions?

sum({<Date={">=$(=max(Date)-x)"}>}Sales)

mrichman
Creator II
Creator II
Author

Hi Mikael,

Thanks for the prompt reply and recommendation. However I'm really requiring the trigger on 'Select in Field' and automatically filtering it to the last 7 or x days. If you can help me, then that would be great

Thanks in advance!

mikaelsc
Specialist
Specialist

Set trigger to select multiple values in a field from a variable

so i guess you could define a selectVariable containing the concatenated values you want.

those concatenated values could be variables themselves (max date -1;-2;-3;...)

not tested myself yet. just imagining...

petter
Partner - Champion III
Partner - Champion III

Often relative date fields are very helpful in situations like this.

You can create a field called DaysAgo in your load script and then simply do this:

Sum( {<DaysAgo={"<7"}>} Sales )

If you have a data island table with a field called #DaysAgo with the values 1 to 7 that your users can select from in tha filterpane you can have this measure:

Sum( {<DaysAgo={"<$(=Max(#DaysAgo))"}>} Sales )

Data Island Table: A table not having any key that connects it to any field in your normal data model.

DAYSAGO:

LOAD IterNo() AS #DaysAgo AUTOGENERATE 7;

The #DaysAgo field will act as your "trigger" to let the user select how many days they want to include in their analysis.

maxgro
MVP
MVP

Look at the attachment

When you click on the numdays field, the trigger (menù --> settiings  --> document properties --> triggers)

filters the dates on the d field.

The expression for the search string is

='(' & '"' & concat(DISTINCT {$ <d={">=$(=date(Today()-max(numdays)+1))<=$(=date(Today()-0))"}>} d, '"' & '|' & '"') & '"' & ')' 

For numdays = 7

     ("07/05/2018"|"08/05/2018"|"09/05/2018"|"10/05/2018"|"11/05/2018"|"12/05/2018"|"13/05/2018")

seven days including today

1.png

maxgro
MVP
MVP

another option is

Relative Calendar Fields