Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Replacing if with set

Hi Guys.

I know how to replace if with set analysis when expression matters only on one variable but how to replace it in this case?

Sum(if(WhStockBalance>=ReservedQty,ReservedQty,WhStockBalance)*UnitCostPrice)

I need to have some fields ignored over selections but i can't figure it out how to convert this expression into set analysis

Thanks

1 Solution

Accepted Solutions
anbu1984
Master III
Master III

Replace Field_To_Be_Ignored by your field name

Sum({<Field_To_Be_Ignored=>} if(WhStockBalance>=ReservedQty,ReservedQty,WhStockBalance)*UnitCostPrice)

View solution in original post

8 Replies
alexandros17
Partner - Champion III
Partner - Champion III

Set Analysis doesn't execute a contitional evaluation so I think you cannot change your if condition with set analysis ...

anbu1984
Master III
Master III

Replace Field_To_Be_Ignored by your field name

Sum({<Field_To_Be_Ignored=>} if(WhStockBalance>=ReservedQty,ReservedQty,WhStockBalance)*UnitCostPrice)

Clever_Anjos
Employee
Employee

If you need to ignore selections into Field 1

Sum({<Field1=>}if(WhStockBalance>=ReservedQty,ReservedQty,WhStockBalance)*UnitCostPrice)

Clever_Anjos
Employee
Employee

I think you can use RangeMin in order to replace your IF too

Sum({<Field1=>} Rangemin(WhStockBalance,ReservedQty)*UnitCostPrice)

gsbeaton
Creator II
Creator II

Hi Julius,

You're going to have to do something like:


IF(WhStockBalance>=ReservedQty,

SUM(ReservedQty*UnitCostPrice),

SUM(WhStockBalance*UnitCostPrice)

)


A bit more verbose than you wanted, but should work.


George

Not applicable
Author

Wow guys thanks i can ignore now. I will give another question then. Can i combine fields that needed to be ignored and the field value to be selected. For example now i can ignore Field1 and how to set the Field2 value = 1?

Clever_Anjos
Employee
Employee

Sum({<Field1=,Field2={"1"}>} Rangemin(WhStockBalance,ReservedQty)*UnitCostPrice)

gsbeaton
Creator II
Creator II

Sorry, I missread your original question,  to follow with your subsequent question, yes, you can combine fields to be ignored with ones to be respected.  You do the following

Sum({<Field1=, Field2=, Field3={'Field to filter on'}>}if(WhStockBalance>=ReservedQty,ReservedQty,WhStockBalance)*UnitCostPrice)