15 Replies Latest reply: Jun 1, 2018 11:20 AM by Josh Akehurst

# Set Analysis - Last 90 Days

I'm attempting to use Set Analysis in Qlik Sense to filter a date range based on the last 90 days.  Using the expression below does not seem to have any effect.  I've tried various combinations, but just can't get anything to work.  The dimension in this scenario is Interaction Start Date Local.

=Avg({\$<[Interaction Start Date Local]=\${">=today()-90"}>}Duration)

• ###### Re: Set Analysis - Last 90 Days

Josh,

your syntax does not seem to be correct.

Try the following:

Avg({\$<[Interaction Start Date Local]={">=\$(=Today()-90)"}>}Duration)

Marc

• ###### Re: Set Analysis - Last 90 Days

=Avg({\$<[Interaction Start Date Local]=\${">=\$(=Date(Today()-90))"}>} Duration)

• ###### Re: Set Analysis - Last 90 Days

Thanks for the tip, but no matter how I modify this expression Qlik basically ignores the parameter for date range (-30, -60, etc.).  I'm at loss on how to make this work.

• ###### Re: Set Analysis - Last 90 Days

Josh,

make sure you don't have any selections made on the date field in the set analysis expression. Otherwise it won't work. To avoid this you can add the following to you set analysis.

Avg({\$<[Interaction Start Date Local]={">=\$(=Today()-90)"},[Interaction Start Date Local]=>}Duration)

The extra addition for the Interaction Start Date Local is to make sure the selections on this field are ignored.

Marc

• ###### Re: Set Analysis - Last 90 Days

Are you making in another date and time related field? such as Month?

• ###### Re: Set Analysis - Last 90 Days

And what is the format of you date? It might be that you have to convert it to a date. When using expressions like Today()-30 it converts the date to a number. When you date field is not a number it won't work.

Avg({\$<[Interaction Start Date Local]={">=\$(=Date(Today()-90))"}, [Interaction Start Date Local]=>}Duration)

• ###### Re: Set Analysis - Last 90 Days

In the data load it's defined as SET DateFormat='M/D/YYYY';

• ###### Re: Set Analysis - Last 90 Days

Are you making selection in another date related field?

• ###### Re: Set Analysis - Last 90 Days

Hi Sunny - I am not making a selection on another date field.

• ###### Re: Set Analysis - Last 90 Days

Try this

=Avg({\$<[Interaction Start Date Local] = \${">=\$(=Date(Today()-90, 'M/D/YYYY'))"}>} Duration)

Assuming, Interaction Start Date Local is in the format M/D/YYYY... if it is not, then you can do this

LOAD Date([Interaction Start Date Local]) as [Interaction Start Date Local]

and then this

=Avg({\$<[Interaction Start Date Local] = \${">=\$(=Date(Today()-90))"}>} Duration)

Also, look here

Dates in Set Analysis

• ###### Re: Set Analysis - Last 90 Days

Good stuff thanks for sharing.  Unfortunately, nothing seems to work which is rather frustrating.  Looking at our data set it would seem everything should line up correctly, but implementing the Date clause in the expression has no effect.

• ###### Re: Set Analysis - Last 90 Days

Josh,

is there a way you could send us the qvf? This way I can take a deeper look at it.

I got it working on one of my dashboards so must me a small thing.

Marc

• ###### Re: Set Analysis - Last 90 Days

Unfortunately I can't share the qvf file due to data / privacy restrictions.

• ###### Re: Set Analysis - Last 90 Days

Unfortunately I can't share the qvf file due to data / privacy restrictions.  Thanks for the offer though.

• ###### Re: Set Analysis - Last 90 Days

Sunny - I tried adding the \$ as described, but nothing changed.

• ###### Re: Set Analysis - Last 90 Days

Would you be able to share the same image like above with this expression

=Avg({\$<[Interaction Start Date Local] = {">=\$(=Date(Today()-90, 'M/D/YYYY'))"}>} Duration)

• ###### Re: Set Analysis - Last 90 Days

Thanks this works!

• ###### Re: Set Analysis - Last 90 Days

Are you may be missing the dollar sign expansion?

=Avg({\$<[Interaction Start Date Local] = \${">=\$(=Date(Today()-90))"}>} Duration)