Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
gauthamchilled
Creator
Creator

how to simplify this if statement

hi all

i have this condition, regardless of revenue if profit is positive number i have to show +ve margin otherwise negative number

how can I achieve this?

if sum(profit) < 0 and sum(revenue) < 0, -(sum(profit)/sum(revenue)

if sum(profit) < 0 and sum(revenue) > 0, -(sum(profit)/sum(revenue)

if sum(profit)> 0 and sum(revenue) < 0, (sum(profit)/sum(revenue)

if sum(profit)> 0 and sum(revenue) > 0, (sum(profit)/sum(revenue)

can you simplify the above if statement?

Regards

Gautham

10 Replies
Anil_Babu_Samineni

May be this?

if(RangeSum(profit, revenue) < 0, -RangeSum(profit,revenue),

if(sum(profit) < 0 and sum(revenue) > 0, -RangeSum(profit, revenue)

if(sum(profit)> 0 and sum(revenue) < 0, RangeSum(profit,revenue)

if( RangeSum(profit, revenue) > 0, RangeSum(profit,revenue)))))

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful