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: 
linoyel
Specialist
Specialist

Division zero constraint

Hi,


In chart dimension calculation, I have a division, but we know that it's impossible to divide  into zero. Here's my calculation:

(Sum(INCOME) / (Sum(COST)+ Sum(SALARY))) - 1 


The result is percent.

If (Sum(COST)+ Sum(SALARY) = 0, then the result should be 100%.


How to write it? Pls help!

1 Solution

Accepted Solutions
Not applicable

HI linoy

try this expression:

if((sum(Cost)+sum(Salary))=0,1,(Sum(INCOME) / (Sum(COST)+ Sum(SALARY))) - 1 )

View solution in original post

16 Replies
luis_pimentel
Partner - Creator III
Partner - Creator III

Try something like:

IF ( (Sum(COST)+ Sum(SALARY) = 0, 1,(Sum(INCOME) / (Sum(COST)+ Sum(SALARY))) - 1  )

kiranmanoharrode
Creator III
Creator III

Hello Linoy,

Please post a sample(Scenario) application for better understanding

Regards,

Kiran

Not applicable

HI linoy

try this expression:

if((sum(Cost)+sum(Salary))=0,1,(Sum(INCOME) / (Sum(COST)+ Sum(SALARY))) - 1 )

vikasmahajan

Expression is

IF(  Sum(COST)+ Sum(SALARY) >0,(Sum(INCOME) / (Sum(COST)+ Sum(SALARY))) - 1 ,0)

in Numbers select show in %.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
linoyel
Specialist
Specialist
Author

Well, I'm confused myself.. no, it's not supposed to be 100%, cause let's say if:

case 1:

I invested 100 and sold 120, so my ROI would be ((120/100)-1)*100 = 20%

case 2:

I invested 100 and sold 80, so my ROI would be ((80/100)-1)*100 = -20%

case 3:

WHAT HAPPENS IF I INVEST 0 and sell 100??

What's my ROI then??

linoyel
Specialist
Specialist
Author

The thing is that if Sum(COST)+ Sum(SALARY) = 0, then the result is not supposed to be 0 but quite an opposite!

This part (Sum(COST)+ Sum(SALARY)) is my investment. If it's 0, it means that all Sum(INCOME) is a benefit. How much it will be in percents though?..

vikasmahajan

Request you to share sample application so that help you.

Vikas

Hope this resolve your issue.
If the issue is solved please mark the answer with Accept as Solution & like it.
If you want to go quickly, go alone. If you want to go far, go together.
linoyel
Specialist
Specialist
Author

case 1:

I invested 100 and sold 120, so my ROI would be ((120/100)-1)*100 = 20%

case 2:

I invested 100 and sold 80, so my ROI would be ((80/100)-1)*100 = -20%

case 3:

WHAT HAPPENS IF I INVEST 0 and sell 100??

What's my ROI then?? (logically)

Not applicable

Logically, then ROI is infinity.