Skip to main content
Announcements
NEW: Seamless Public Data Sharing with Qlik's New Anonymous Access Capability: TELL ME MORE!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

variable declaration of last year and current year?

Hi

i want to compare sales for current and previous year but i am getting same values for all. pease help

so for that i have declared

current year

curr_year = Max(sold_Year)

previous year

prev_year=max(sold_year)-1

for  expression for current year

=num(sum({<sold_year = {"$(curr_year)"}>}[inv value])/(Sales_INR_Unit),'#,##0.0')

for expression for previous_year

=num(sum({< sold_Year = {"$(=$(prev_year))"}>}

[inv value]/Sales_INR_Unit),'#,##0.0')

for total growth

=num(

sum({<sold_year = {"$(curr_year)"}>}[inv value])

-

sum({< sold_Year = {"$(=$(prev_year))"}>}

[inv value])

/

sum({< sold_Year = {"$(=$(prev_year))"}>}

[inv value]/Sales_INR_Unit),'#,##0%')

1 Solution

Accepted Solutions
its_anandrjs

Ok then try this direct use the Max(sold_Year) on the set expression.

Current Year

=num(sum({<sold_year = {'$(=Max(sold_Year))'}>} [inv value])/(Sales_INR_Unit),'#,##0.0')

Previous Year

=num(sum({< sold_Year = {"$(=Max(sold_Year)-1)"}>} [inv value]/Sales_INR_Unit),'#,##0.0')

View solution in original post

5 Replies
Anil_Babu_Samineni

can you check this in Text box?

=Num(Sum({< sold_Year = {'$(=Max(sold_year)-1)'}>} [inv value]/Sales_INR_Unit),'#,##0.0')

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

i have taken in text box (circlen in black color) its giving the same value as in charts totalkkkk.png

Anil_Babu_Samineni

Good, Is that value is the same for Current Year / Different? Remove Red part and try. Not sure, What your intend to write different for Curr and Prev. ??

=num(sum({<sold_year = {"$(curr_year)"}>}[inv value])/(Sales_INR_Unit),'#,##0.0')

=num(sum({< sold_Year = {"$(=$(prev_year))"}>} [inv value]/Sales_INR_Unit),'#,##0.0')

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
its_anandrjs

What output you get in

curr_year = Max(sold_Year)

prev_year=max(sold_year)-1

Individually check expression on the text object did you get anything on this objects if not means your year field is string which not give correct result so please check this.

its_anandrjs

Ok then try this direct use the Max(sold_Year) on the set expression.

Current Year

=num(sum({<sold_year = {'$(=Max(sold_Year))'}>} [inv value])/(Sales_INR_Unit),'#,##0.0')

Previous Year

=num(sum({< sold_Year = {"$(=Max(sold_Year)-1)"}>} [inv value]/Sales_INR_Unit),'#,##0.0')