Skip to main content
Woohoo! Qlik Community has won “Best in Class Community” in the 2024 Khoros Kudos awards!
Announcements
Nov. 20th, Qlik Insider - Lakehouses: Driving the Future of Data & AI - PICK A SESSION
cancel
Showing results for 
Search instead for 
Did you mean: 
thomas_2583
Contributor III
Contributor III

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.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
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
Contributor III
Contributor III
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.
Please appreciate our Qlik community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved 🙂
thomas_2583
Contributor III
Contributor III
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