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: 
NickBentley
Contributor III
Contributor III

Variable not summing as anticipated

I am using the following expression to sum the the sales for the next four weeks from last year.

=Sum({<Chron_Week = {"$(dMaxChronWeek-52)"},Fy_Wk=,FY_Year=>}Units_Sold)+ Sum({<Chron_Week = {"$(dMaxChronWeek-51)"},Fy_Wk=,FY_Year=>}Units_Sold)+ Sum({<Chron_Week = {"$(dMaxChronWeek-50)"},Fy_Wk=,FY_Year=>}Units_Sold)+ Sum({<Chron_Week = {"$(dMaxChronWeek-49)"},Fy_Wk=,FY_Year=>}Units_Sold)

The expression is working fine and giving the expected result.

Because I am going to be using the same expression in multiple tables, I have converted it to a variable:

dUnitsLY+4weeks

However, when I write this variable in the expression as $(dUnitsLY+4weeks), I get the overall number(914) listed for every customer and not the customer's individual sales for that period. When I use the extended expression (as above) it does results for individual customers.

Can some please explain why the expression is  giving a different result when wrapped  in the variable?

Thanks in advance!

Cheers,

Nick

 

1 Solution

Accepted Solutions
tresesco
MVP
MVP

While defining the variable, remove the preceding '=' and try.

View solution in original post

2 Replies
tresesco
MVP
MVP

While defining the variable, remove the preceding '=' and try.

NickBentley
Contributor III
Contributor III
Author

Works a treat.

 

Thanks tresesco