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

Announcements
Qlik Connect 2026! Turn data into bold moves, April 13 -15: Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Need a help in if condition query....

Dear All,

             I have a issue on below conditon .......

= sum (if(id=5,value) * if(id=10,value))

id = 5 is Qty

id = 10 is Rate

The above condition is showing zero....

Can any one help me...

Regards,

Antony.

39 Replies
Not applicable
Author

Dear Anand,

                          ID = 10 is Rate and ID = 5 is Qty.

Not applicable
Author

Dear Akbar,

                  i tried this, it's showing more than my actual output.

Pls see the eg. which i showed on above.

Regards,

Antony.

Anonymous
Not applicable
Author

Hi,

You might be having NULL record in the "value" column. Convert it to 0.

Below expression may work,

=sum (if(id=5,if(isnull(value), 0, value)) * if(id=10,if(isnull(value), 0, value)))

Thx

Satya

Anonymous
Not applicable
Author

Antony Napolean,

In a multiplication let us say e.g. A * B. If any of A or B is zero then the product will be zero.

Your condition will always be zero : sum (if(id=5,value) * if(id=10,value)). Is it possible a single line have two values for the field id. The answer is not.

A simple solution is break the table into two tables.

Prod_code  Rate_Id        Rate

1                  10                  5

2                  10                  10

3                  10                  15

4                  10                  20

5                  10                  25

Prod_code Qty_ID           Qty

1                5                     5

2                5                     4

3                5                     3

4                5                     7

5                5                     8

Now the required formula is = sum (Rate * Qty)

Hope this helps!

Regards

MultiView

Not applicable
Author

Dear Satya,

                   Your expression is showing zero on my application.

sujeetsingh
Master III
Master III

Try this

(sum(if(ProductID='A',Number))) * (sum(if(ProductID='D',Number)))

if not doing just post a sample

Thanks.

Not applicable
Author

I already posted a sample. Pls see above.

jagannalla
Partner - Specialist III
Partner - Specialist III

Hello Antony,

Still I'm confuse in your query and explaination. What is the dimension you are consider in the charts ? Because the expression what you are trying to develp is wrong. How can you consider two conditions at a time for a single column in expression.

If condition works record by record of column. We can't develop two conditions to work as single point. Please let us know what is the output you want to see based on input you mention.

In your condition you are trying to get sum of value where Id=10 it is fine. But at same level you are trying to get sum of value where Id=5.

You can go with set analysis.. If you take ProductCode as dimension and expression as

Sum({<Id={10}>}Value)* Sum({<Id={5}>}Value)

Cheers!!

Jagan

Not applicable
Author

Hi Jagan,

             Pls find below my eg.

   

Product codeIdValue
1105
21010
31015
41020
51025
155
254
353
457
558

My output is 450.

I  want  to show the total sales.

for my sales formula is Sales = (Qty * Rate). i have qty and rate both values in one field. so i need to separate the qty and rate by using id 5 and 10.

I need the above output 450 , how will i get ?.

Regards,

Antony

jagannalla
Partner - Specialist III
Partner - Specialist III

You can go with set analysis.. If you take straight table ProductCode as dimension and expression as

Sum({<Id={10}>}Value)* Sum({<Id={5}>}Value).

Now in Expression tab of ST -> Total Mode as Expression Total. Now you can see total count in top of expression.

Cheers!!

Jagan