Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

how to declare a variable ?

Hi

I want to compare two years sale ie the current year should be the 2017 and prev year should be either 2016,2015 or any other year less that 2017

so in my script i have declared my variable as :-

Let currentdate =DATE(Today(1)-1,'YYYYMMDD');

Let Curr_Year = Year(Today());

let prev_year=..............

createdate is a column in database

Date#(CreateDate, 'YYYYMMDD') as Sold_Date,
month(Date#(CreateDate, 'YYYYMMDD')) as Sold_Month,
year(Date#(CreateDate, 'YYYYMMDD')) as Sold_Year,


in my expression i have expression for prev_year and curr_year

curr_year expression:-


=num(
sum(if(Sold_Date <= MakeDate(Curr_Year,month(To),day(To)) and Sold_Date >= MakeDate(Curr_Year,month(From),day(From)),  [inv value]))/Sales_INR_Unit,
'#,##0.0')

for prev_year

=num(
sum(if(Sold_Date <= MakeDate(Prev_Year,month(To),day(To)) and Sold_Date >= MakeDate(Prev_Year,month(From),day(From)),  [inv value]))/Sales_INR_Unit,
'#,##0.0')

Now what all changes are required for prev_year expressions? and for prev_year variable declration????????

27 Replies
Anonymous
Not applicable
Author

its giving an error

syntax error

Anil_Babu_Samineni

What you've done? Can you share image?

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
Anonymous
Not applicable
Author

abccccccccccccccccccc.png

Let Prev_Year = AddYears('2017-10-12',-2);

when i am using this in variable

Anil_Babu_Samineni

What you shown is working?

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
Anonymous
Not applicable
Author

now yo want me to use these variables instead of these?

Let currentdate =DATE(Today(1)-1,'YYYYMMDD');
Let Curr_Year = Year(Today());
Let Prev_Year = (Year(Today())-1);

Anonymous
Not applicable
Author

variable used in text box is working but charts are not showing results, it can be seen in image

Anil_Babu_Samineni

Yes? You can play with that your needed. Because, Still 100's reply are not helpful if thread owner not explaining clear and needed

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
Anonymous
Not applicable
Author

actually i dont want entire date. i only want year to like instead of 10/12/2015. i want only 2015

Anil_Babu_Samineni

How come i know what expression you attempt?

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
Anil_Babu_Samineni

What we try everything available from Qlikview Cookbook | Recipes for Qlikview Success

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