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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Expression Vs Variable Expression

Dear Team,

i am using a Expression in a TEXT object in 2 different way and getting 2 different out but

my Max MonthYear is  : Feb-2015.

1. ) =date(addmonths(max(MONTHYEAR),-3), 'MMM-yyyy')  OUTPUT : Nov-2014   ( Correct )

2. ) =date( $(=AddMonths(max(MONTHYEAR),-3)),'MMM-yyyy') OUTPUT : Dec-1899 ( Wrong)

if i am removing Date() function then its show numeric value as below :

3) =$(=AddMonths(max(MONTHYEAR),-3)) OUTPUT : 0.0054617676266137

Kindly let me know what is the issue.

Actually i want to get last 3 Month sum of Turnover so i need to use this into the set analysis.

Thanks & Regards,

JKV

Labels (1)
7 Replies
prieper
Master II
Master II

Would be good to post an example and to see your data-formats.

It may also help to copy your formulas into a straight table and leave the expression label empty. On mouse-over you then can see the individual values used for the calculation.

Peter

Not applicable
Author

below is what i am getting.. label is showing right information but the expression showing wrong

MONTHYEAR 11/1/2014
12/30/1899
Feb-201512/30/1899
Not applicable
Author

use this instead and you will get the same output as =date(addmonths(max(MONTHYEAR),-3), 'MMM-yyyy')

= date($(=new),'MMM-YYYY')

new is a variable with value- AddMonths(date(max(Date)),-3)

Not applicable
Author

yes i know if i use into a variable i get the information but why for such small expression i use variable.

even lots of example in qlikview community show that you can direct use such expression in set analysis.

Colin-Albert
Partner - Champion
Partner - Champion

The $(= )  applied to the date is calculating the values in the date as numbers divided by the various date parts.

So $(= 27/3/15)  gives   27/3 = 9  then 9/15 = 0.6 !

     $(= 27/3/2015) gives     27/3 = 9  then 9/2015 = 0.00446650124 !

Not applicable
Author

Dear Colin,

But why the below expression showing two different result.

In the Label is showing the right information, but in Expression it showing the wrong.

=date( $(=AddMonths(max(MONTHYEAR),-3)),'MMM-yyyy')

MONTHYEAR11/1/2014
12/30/1899
Feb-201512/30/1899

Anonymous
Not applicable
Author

with your above code you will get last 2 months and plus current MTD

to get last 3 months you will have to select data where Date <=Date(=monthstart(today())-1))

AND Date >=Date(=MonthStart(MonthStart(Today())-85)


And if you can upload sample qvw that would be great to help !