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

Announcements
Posting on Qlik Community is temporarily paused for some users. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
parthesh
Creator
Creator

Expression is not working as per expectation.

Hello all,

i have one expression in which i am trying to find percentage as per below.

((Sum({< REC_TYPE={InvoiceDateRec}>}if(ARCOST_TOTAL_COST>=0 or ARCOST_TOTAL_COST<=0,(RAGLDA_ACCTD_AMOUNT*XRATE_CONST*RATE)))

-

Sum({<  REC_TYPE={InvoiceDateRec}>} if(ARCOST_TOTAL_COST>=0 or ARCOST_TOTAL_COST<=0,(ARCOST_TOTAL_COST*XRATE_CONST*RATE))))

/

(Sum({< REC_TYPE={InvoiceDateRec}>} (RAGLDA_ACCTD_AMOUNT*XRATE_CONST*RATE))))

*100

Basically it is ((sales - cost) / sales)*100 .

here when i put whole above expression it is showing wrong result. but when i create seperate column for (sales-cost). and one more column for (sales) and calculating final percentage column using "column()"   like column(1)/column(2)  it is showing correct result.

1.png

thanks in advance.

Labels (1)
4 Replies
marcus_sommer
MVP
MVP

Maybe this made a difference:

(rangesum(sales, -cost) / sales)*100

- Marcus

sunny_talwar
MVP
MVP

Why do you need the if statement here? If ARCOST_TOTAL_COST is a number, then it will either be greater than equal 0 or less than equal to 0... are you checking if it is text???


Also, it should not matter, but Sales in the numerator have a different expression than sales in the denominator??

parthesh
Creator
Creator
Author

Hello Sunny,

to avoid null we are doing that.

sunny_talwar
MVP
MVP

Nulls can be avoided like this in set analysis

ARCOST_TOTAL_COST = {"*"}