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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
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!

1 Solution

Accepted Solutions
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

View solution in original post

14 Replies
eduardo_sommer
Partner - Specialist
Partner - Specialist

You probably inverted the then/else in the if

Try with:

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

Eduardo

pgalvezt
Specialist
Specialist
Author

Hi Eduardo,

Still gives the same total 4900,

Thanks

eduardo_sommer
Partner - Specialist
Partner - Specialist

Can vou share your qvw or at least part of it?

Eduardo

pgalvezt
Specialist
Specialist
Author

Eduardo,

The real result is -4714

The wrong result is 4874

Thanks!

eduardo_sommer
Partner - Specialist
Partner - Specialist

When I tried to open the app, it asked for a userid and password. Please, disable Section Access.

Eduardo

Joseph_Musekura
Support
Support

Hi,

Can you verify if, in the property of expression in you have checked Expression Total or Sum of rows?

expressionTotal.png

This selection would affect the result

regards,

Joseph_Musekura
Support
Support

I did not mention that this concerns "straight table". If you have a pivot table , no need to check.

pgalvezt
Specialist
Specialist
Author

Im Sorry,

Section Access was deleted,

Thanks!

eduardo_sommer
Partner - Specialist
Partner - Specialist

Good morning , Pablo

Why do you use Consumo12 in one object and Consumo12a in the other. The object with Consumo12a is giving you the result you expected.

Please, send me more details, since I don't have the data sources.

Eduardo