# New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
cancel
Showing results for
Did you mean:
Contributor II

## Set analysis expression for min and max date by default

Hi All,

i need a chart calculation which is sum (sales) has to shown for latest 10 days by default if there is no date selection made. if any date selection done then show accordingly. attached the sample data. Please help.

TIA

Labels (2)

• ### Qlik Sense

1 Solution

Accepted Solutions

Apologies, I forgot to save the file.

Here is the saved one.

Regards,
Kaushik
10 Replies

Try this,

Sum({<Date = {">=\$(=Max(Date)-10)"}>}Sales)

Regards,
Kaushik
Contributor II
Author

Hi Kaushik,

Thanks and yes this is working fine. But the problem is. i have 10 fields in the data file. when user opening the dashboard there wont be any selections. if during that time only i want to latest 10 days data in my chart if started selecting the fields then my measure must show the values as per the selection.

Eg: i want my expression is something like this

if ("no filter selected" then Sum({<Date = {">=\$(=Max(Date)-10)"}>}Sales) else sum(Sales))

not sure how to get the red colour expression

TIA

Hi,

In such case, you can create a variable say vFilter

vFilter will have an expression like below.

=If(GetSelectedCount(Date)=0,'<Date = {">=\$(=Date(Max(Date)-10))"}>','\$')

And use this in the expression like below.

Sum({\$(vFilter)}Sales)

Regards,
Kaushik
Contributor II
Author

Hi Kaushik,

Thanks for your prompt reply. this one gives me '0' values. i am not sure how to call the variable in set analysis.

Here is the qvf file for your reference.

Regards,
Kaushik
Contributor II
Author

Hi Kaushik,

no sheet in your qvf and attached the qvf with sheets which has no values in sales measure (Variable measure).

PFA

Contributor II
Author

hi kaushik,

Actually, the below expression is working fine. but if user selection is not from the date then its not working.

=If(GetSelectedCount(Date)=0,sum({<Date = {">=\$(=Max(Date)-10)"}>}sales),sum(sales))

Apologies, I forgot to save the file.

Here is the saved one.

Regards,
Kaushik