Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sakshikaul
Creator II
Creator II

to write expression using variable

Hi

I have a variable named daysOfComparison declared as follows:-

=date(lastDate)-compday

where compday is the value entered by user for comparing no. of days.

Lets say if user enters 5 as comparison no. of days input box  then the sales for 10/5/2018 will be displayed in chart as per formula mentioned above in variable

Note last date is 10/10/2018

Following is the image for above explanation

PAINT2.png

Now I want to write an expression for the same ie when user selects comparison(no. of days )=5 then sales for 10/5/2018 should be displayed

How to write an expression?

16 Replies
sakshikaul
Creator II
Creator II
Author

if I am entering compday as 7 then I am getting value as 10/7/2017

sakshikaul
Creator II
Creator II
Author

here both the expression are giving me same values

=Sum({<sold_Date = {"=$(=Date(date(Sold_Date)))"}>} [inv value])

and

=Sum({<Sold_Date = {"=$(=Date(date(Sold_Date) - $(compday)))"}>} [inv value])

why?

Anil_Babu_Samineni

Try this?

Sum({<sold_Date = {"=$(=Date(Max(sold_Date) - $(compday)))"}>} [inv value])

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sakshikaul
Creator II
Creator II
Author

I want the variable which I am using here below in the image ie DaysOfcomp  should be used in expression

so my expression will be this? This below expression is giving an error, Please help me in correcting this. Rest is done

=Sum({<lastDate = {=Date(DaysOfComp)}>} [inv value])

Anil_Babu_Samineni

You said that DaysofComp is number which comes thru input box, And you are using Date format for that. Qlik can't identify as DD or MM or YYYY. Not really sure what you mean to first message and Different than  Last Message. BTW, You expression Wrong - Check the set analysis rules here https://www.analyticsvidhya.com/blog/2014/01/set-analysis-qlikview/

And More over, You need to convert input box to Date then my suggestion would be this - https://help.qlik.com/en-US/qlikview/November2017/Subsystems/Client/Content/Scripting/DateAndTimeFun...

If None of them are not working - We may ask input and output result which you want to see Here are the some tips

Uploading a Sample

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
sakshikaul
Creator II
Creator II
Author

DaysOfComp is not a number. It is in date format

value of DaysOfComp is calculated in following formula

=(lastDate)-compday

and when DaysOfcomp is taken as a text  box its value is shoen below

PAINT2.png

sakshikaul
Creator II
Creator II
Author

Hi I am not able to see 'use advanced editor option' to upload application

PAINT2.png