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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
pgalvezt
Specialist
Specialist

Sentence With Script

Hi,

I have this

Load

[conA1        ] + [conB1        ]  as TotalSum

From Table1;

My Expression Sum(TotalSum) thrown 5000

but I want to add an if sentence

Load

If([conA1        ] + [conB1        ] >0,'0', [conA1        ]+ [conB1        ])as TotalSum,

From Table1;

My Expression Sum(TotalSum) thrown 4900

I need to appear 5000

How Could it be?

Thanks!

14 Replies
pgalvezt
Specialist
Specialist
Author

Good Morning,

The real object is the if sentence, the other one (Consumo12a) is for check the real result. I don´t know why when I use If the final result change in the script.

eduardo_sommer
Partner - Specialist
Partner - Specialist

You have some positive values in the inv-consumoso12 field, with zero in the corresponding inv-consumowo12. According to your if statement, when the sum of inv-consumoso12 plus inv_consumowo12 is positive, ignore them, changing the result to 0. This gives the difference in the results.

For the product PV04IM-32-9928 that came selected in your app, inv-consumowo12 is 0 for all rows and inv-consumoso12 has some positive values.

Eduardo

pgalvezt
Specialist
Specialist
Author

I understand that, so how could be the best if sentence and give 4714?

Thanks!

eduardo_sommer
Partner - Specialist
Partner - Specialist

Hi Pablo,

I think I'm missing something in this question. You have an expression to calculate a field, called Consumo12a, which gives you the right result. This expression has no if. It simply makes the sum of two fields. Why do want to achieve, in the calculation of Consumo12, with that IF. Excluding the positive sums gave you the wrong results. Maybe you don't need that if and use the same expression as that of Consumo12a.

Please, tell me what I'm getting wrong from your question.

Eduardo

pgalvezt
Specialist
Specialist
Author

I did the follow:

If(Sum(Consumo12) < '0','0',Sum(Consumo12))+Sum(Despacho) Now Works for that expression.

I just I have to change all Consumo12 ,11 and 10 for that expression.

Thanks Eduardo. I marked your suggestion as better answer.