Qlik Community

New to Qlik Sense

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

Announcements
Tell us which business and trade publications you read most regularly: RESPOND NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
loganathan
Contributor II
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)
1 Solution

Accepted Solutions
kaushiknsolanki

Apologies, I forgot to save the file.

Here is the saved one.

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".

View solution in original post

10 Replies
kaushiknsolanki

Try this,

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

 

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
loganathan
Contributor II
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

kaushiknsolanki

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
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
loganathan
Contributor II
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. 

kaushiknsolanki

Here is the qvf file for your reference.

 

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
loganathan
Contributor II
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

loganathan
Contributor II
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))

kaushiknsolanki

Apologies, I forgot to save the file.

Here is the saved one.

Regards,
Kaushik
If reply is satisfactory, please "Like" the post.
If reply is solution, please mark as "Correct".
loganathan
Contributor II
Contributor II
Author

Hi Kaushik,

its not working if i check year and month field. update the file with extra data as attached. please refer bookmark for my selection.

loganathan_0-1593879823244.png