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

If condition

Hello Qlik folks,

Some one please explain what this below if condition means

if (COMPCOST_OPENPO_NOOH_Ind_In = 0 and alt(ITEM_CURRENT_MATL_COST_BOM_In,0) > 0,  alt(ITEM_CURRENT_MATL_COST_BOM_In,0) * BOM_USAGE_In + alt(ITEM_CURRENT_MATL_OH_COST_BOM_In,0) * BOM_USAGE_In, COMPCOST_OPENPO_In) as COMPCOST_OPENPO_In2,


Thanks,

D

1 Solution

Accepted Solutions
jayanttibhe
Creator III
Creator III

Your Expression - rewritten so that it will be easy to read

if (COMPCOST_OPENPO_NOOH_Ind_In = 0 and alt(ITEM_CURRENT_MATL_COST_BOM_In,0) > 0,           

     alt(ITEM_CURRENT_MATL_COST_BOM_In,0) * BOM_USAGE_In

  +

alt(ITEM_CURRENT_MATL_OH_COST_BOM_In,0) * BOM_USAGE_In, COMPCOST_OPENPO_In

)

as COMPCOST_OPENPO_In2,

First of all Alt Function - 

The Alt function is a conditional function and returns the first of the parameters that has a valid numeric Representation (Including dates). If no such match is found, it will return the last parameter (Last value in the list). Any number of parameters can be used.

alt(case1[ , case2 , case3 , ...] , else)

So in your case Any non numeric value Or null will be defaulted with '0' due to Alt function.

So - If  COMPCOST_OPENPO_NOOH_Ind_In = 0  AND ITEM_CURRENT_MATL_COST_BOM_In > 0   - If both these conditions met

then -

SUM up

alt(ITEM_CURRENT_MATL_COST_BOM_In,0) * BOM_USAGE_In  

AND

alt(ITEM_CURRENT_MATL_OH_COST_BOM_In,0) * BOM_USAGE_In

IF NOT

then -

COMPCOST_OPENPO_In

AS

COMPCOST_OPENPO_In2

View solution in original post

2 Replies
jayanttibhe
Creator III
Creator III

Your Expression - rewritten so that it will be easy to read

if (COMPCOST_OPENPO_NOOH_Ind_In = 0 and alt(ITEM_CURRENT_MATL_COST_BOM_In,0) > 0,           

     alt(ITEM_CURRENT_MATL_COST_BOM_In,0) * BOM_USAGE_In

  +

alt(ITEM_CURRENT_MATL_OH_COST_BOM_In,0) * BOM_USAGE_In, COMPCOST_OPENPO_In

)

as COMPCOST_OPENPO_In2,

First of all Alt Function - 

The Alt function is a conditional function and returns the first of the parameters that has a valid numeric Representation (Including dates). If no such match is found, it will return the last parameter (Last value in the list). Any number of parameters can be used.

alt(case1[ , case2 , case3 , ...] , else)

So in your case Any non numeric value Or null will be defaulted with '0' due to Alt function.

So - If  COMPCOST_OPENPO_NOOH_Ind_In = 0  AND ITEM_CURRENT_MATL_COST_BOM_In > 0   - If both these conditions met

then -

SUM up

alt(ITEM_CURRENT_MATL_COST_BOM_In,0) * BOM_USAGE_In  

AND

alt(ITEM_CURRENT_MATL_OH_COST_BOM_In,0) * BOM_USAGE_In

IF NOT

then -

COMPCOST_OPENPO_In

AS

COMPCOST_OPENPO_In2

chrismarlow
Specialist II
Specialist II

Is maybe easier to read if you break up the parts of the IF statement and indent (also indenting the + in the value if true as it keeps wrapping around on me);

if (COMPCOST_OPENPO_NOOH_Ind_In = 0 and alt(ITEM_CURRENT_MATL_COST_BOM_In,0) > 0,

     alt(ITEM_CURRENT_MATL_COST_BOM_In,0) * BOM_USAGE_In

          + alt(ITEM_CURRENT_MATL_OH_COST_BOM_In,0) * BOM_USAGE_In,

     COMPCOST_OPENPO_In

) as COMPCOST_OPENPO_In2,

alt function just takes the first numeric in the list supplied, so in this case is a shorter way of returning 0 when the fields are empty/null.

Cheers,

Chris.