Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for
Did you mean:
Not applicable

## Why is my chart treating negative values as positive values?

I have an expression which give a positive or negative value depending on whether a field PURCHASE_SALE is 'P' or 'S'

IF(PURCHASE_SALE='P',SUM(PRICE*NOMINAL/-100),SUM(PRICE*NOMINAL/100))

When displayed in a straight table and selecting the Total Mode and 'Sum of Rows' i get the expecting total displayed.

However when using the same expression in a bar chart (the only dimension is calendar week), it seems to ignore the fact half the values are negative and adds them all up as if they were positive. Wyy is this?

How can i get my bar chart to treat the negative as negative vaules?

1 Solution

Accepted Solutions
Not applicable
Author

Actually, Kumar that didn't work, but this did. I didn't need the SUMs within the IF statement

SUM(IF(PURCHASE_SALE='P',PRICE*NOMINAL/-100,PRICE*NOMINAL/100))

4 Replies
Anonymous
Not applicable
Author

If statement will work only when the specific field is available in the dimension.

IF(PURCHASE_SALE='P',SUM(PRICE*NOMINAL/-100),SUM(PRICE*NOMINAL/100)) as Measure

from <table name>

group by <field names>

In fact you can calculate this at script level and just use sum(Measure) as expression,

it will solve your issue...

Regards

Nitin

MVP

Partner - Specialist

HI,

Include over all sum. then you will get currect total.

Ex:

Sum(IF(PURCHASE_SALE='P',SUM(PRICE*NOMINAL/-100),SUM(PRICE*NOMINAL/100)))

Not applicable
Author

Actually, Kumar that didn't work, but this did. I didn't need the SUMs within the IF statement

SUM(IF(PURCHASE_SALE='P',PRICE*NOMINAL/-100,PRICE*NOMINAL/100))

Community Browser