Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Variable in expression

Hi, i am trying to use a variable in an expression using IF statement as shown below.

without the IF statement, if i pull the variable in a table i get the required values but when i use the IF statement i am not getting any values. This could be due the the way i am calling variables but i am not able to figure the correct way.

Any help is much welcome !!

Data:

Stock field contains stock quantity

Qty field Contains inbound quantity

Variables:

1) Stock_Launch_1 (Structure: Add current Stock & inbound stock then reduce sales till launch week ; definition:

////////////////////////////////

sum( total <[Item Code], [Item 2735D Ssn],DeptName,GroupName> {<Store = {"=left(Store,3) like('SOH')"}>

+

<Store = {"=left(Store,3) like('CDC')"}>} Stock) + sum({<[Expected WHSE delivery Week] = {"<$(=($1))"}>}Qty)

-  rangemin(sum(aggr(sum([Last 13 Weeks sale qty]/13),[Item Code],[Item 2735D Ssn],DeptName,GroupName))*(($1)- 200-$(Week No.)), sum(  {<Store = {"=left(Store,3) like('SOH')"}> + <Store = {"=left(Store,3) like('CDC')"}>} Stock))

)

/////////////////////////////////////

2) Launch (Structure: Number ; definition: 442)

3) Week No. (Structure: Number; definition: 40)

expression to calculate stock: $(Stock_Launch_1($(Launch))) - works well

expression using IF statement: sum(aggr(if($(Stock_Launch_1($(Launch))) > 0,1,0),[Item Code]))- DOESN'T work

P.S. I realized that if I define the variable Stock_Launch_1 to use Launch as a parameter & NOT $(Launch) the if statement works - no idea why but i can not use it that way.

3 Replies
Anil_Babu_Samineni

Can you try if.. statement alone without sum(aggr(...)) initially

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

Hi Anil - I tried it and it doesn't work in either form:

Form 1 - variable that uses (Launch) as a parameter: sum((if($(Stock_Launch_1($(Launch))) > 0,1,0)))

Form 2 - variable that uses ($Launch) as parameter: sum((if($(Stock_Launch(Launch)) > 0,1,0)))

P.S. I am trying to get the output in a table with Item Code as a dimension as shown below. The IF statement is for the expression "Avail" which returns a 0 OR 1 based on the IF statement.

Capture.JPG

Anil_Babu_Samineni

Did you find the solution? Or still expecting

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