Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
ashis
Creator III
Creator III

how to get last 5 days using calculated dimesion in qliksense

Hi,

In qliksense i have created one calculated dimension using this logic

Days=if(Rep_Field='Current Month By Day',Date_Period), this is giving me number of days such as 1,2,3,4,.....31

Now i have one bar chart where i am using region as 1st dimension and the 2nd dimension (the above one) is the Days.

now i want to last 5 days of data in this chart. so i am using this as expression.

Sum({<Date_Period={‘>=$(=Date(Max(MyDate)-5),'DD')<=$(=Date(Max(MyDate),'DD'))’}>} Val )

MyDate has only one date as =DD/MM/YYYY format.

I am unable to get this to work.

6 Replies
ChiragPradhan
Creator II
Creator II

If you want to use your current expression, use this one -

Sum({<Date_Period={">=$(=Date(Max(MyDate)-5),'DD')<=$(=Date(Max(MyDate),'DD'))"}>} Val )

However, since you are using the Max of your date field, the easier expression is this one -

 

Sum({<MyDate={">$(=Date(Max(MyDate)-5))"}>} Val )

 

Regards,

Chirag

ashis
Creator III
Creator III
Author

Hi Chirag,

Thank you for your reply. i see you only change the double quote instead of single quote apart from that the syntax is same.

unfortunately it did not work though.

Date_Period and MyDate coulums are two different colums.

MyDate column will have only one date value and it will take only "DD" part (number of days) and that needs to match with Date_Period columns and get 5 days of data.

So , MyDate will have value like = "MM-DD-YYYY"

and Date_Period will have values like = 1,2,3,4,5,6,7.......31

Thank you,

ashis
Creator III
Creator III
Author

I tried this following syntax

Sum({<Date_Period={">$(=Date((Max(MyDate)-4),'DD'))"}>} Val ) - this is giving me result however it is incorrect.

it is giving more result that the max date returns. For example max(MyDate) has value 27-06-2017  , so i want results of 

27,26,25,24,and 23.

the above syntax is giving 28, 29,30 and 31 result as well.

 

tresesco
MVP
MVP

Working with date fields is tricky. Could you share a sample app to work on?

ashis
Creator III
Creator III
Author

Hi Tresesco, Thank you for your reply, actually i can not share the app due to security reason.

tresesco
MVP
MVP

You can create an app with representative sample data (removing security concern) and share - that way I guess you would get better and faster resolution.