Qlik Community

New to Qlik Sense

If you’re new to Qlik Sense, start with this Discussion Board and get up-to-speed quickly.

Announcements
Customer & Partners, DEC. 9, 11 AM ET: Qlik Product & Strategy Roadmap Session: Data Analytics REGISTER NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
thomas_2583
Creator
Creator

IF Logic

Hi, 

I am trying to write out the correct logic for an IF statement, but the syntax is incorrect, can anyone please shed some light as to what is wrong here please?


if(

count(Purchase_Volume) + $(v_Extra Volume) + (v_Product = 'DIST'), count(Purchase_Volume) + $(v_Extra Volume),
count(Purchase_Volume) + $(v_Extra Volume) + (v_Product = 'TUPA'), count(Purchase_Volume) + $(v_Extra Volume),
count(Purchase_Volume) + $(v_Extra Volume) + (v_Product = 'DGUTA'), count(Purchase_Volume) + $(v_Extra Volume)

,0)

5 Replies
PrashantSangle

what is v_product??? variable or field??

can you share defination of variable $(v_Extra Volume)

 

Regards,

Prashant Sangle

Great dreamer's dreams never fulfilled, they are always transcended.
GaryGiles
Specialist
Specialist

In response to your previous question, if you have product as a dimension in your table, the following should give you the behavior you were looking for:

count(Purchase_Amount)+if(Product=$(v_Product),$(v_Extra_Volume),0)

Note: depending on how you variable input is setup, you may need quotes:

count(Purchase_Amount)+if(Product='$(v_Product)',$(v_Extra_Volume),0)

thomas_2583
Creator
Creator
Author

Hi

v_Product is defined from the variable 'Product_Grouped'. I am using v_Product due to having this as a Variable Input Button.

Similar to v_Extra_Volume, this is also a Variable Input (Input Box).

The IF statement (I am hoping) will allow me to then key in 100 to the v_Extra_Volume input box, select v_product button, then my table will update based on these selections. 

PrashantSangle

well if your both field are input variable. out of that 1 input variable is comparing for product name and another for extra volume,

and in all case you just want to add v_extra_volume + count(Purchase_Volume) 

then why don't you just write 

=v_extra_volume+count(Purchase_Volume)

Great dreamer's dreams never fulfilled, they are always transcended.
thomas_2583
Creator
Creator
Author

Thanks for your suggestion Gary, the second option works syntax wise, but the increase still adds to all Products opposed to showing as a 0