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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
marcel_olmo
Partner Ambassador
Partner Ambassador

Division between two negative numbers.

Hey guys. I'm getting some problems calculating some percentages about refunds of sales.

The point is, if I make a division between two negative numbers, the result is positive. And I'm getting a wrong result.

Is there some way I could know if I'm doing this kind of divisions?.

If I know that I only have to change the symbol (positive or negative) of the result, and it will be done.

Thanks in advance!!

Cheers!

Labels (1)
1 Solution

Accepted Solutions
fernandotoledo
Partner - Specialist
Partner - Specialist

THE CORRECT CALCULATION IS


( [ACTUAL] - [PREVIOUS] ) / FABS([PREVIOUS])


WHERE ABS() IS THE ABSOLUTE VALUE FUNCTION

View solution in original post

6 Replies
vgutkovsky
Master II
Master II

Do you mean absolute value (i.e. you always want it to be positive)? If so, the function is fabs()

Regards,

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Ok, here I leave you a real example with an image of a result. (first column is current year, second column is last year, and result)

For me this results are wrong, because you have to change the sign (+/-) of them. I mean, in the first one, I'm having a bad lecture, because I'm going worse than last year, so the result would be in red -28.42%.

How could I get it right?

Many thanks by advance.

Regards!!

vgutkovsky
Master II
Master II

Do you're dividing column(1) by column(2), subtracting 1, and treating that as a percentage? This is kind of confusing...what is this supposed to represent? And for the first row, why do you say you're doing worse than last year: -21.904 > -28.128, right? Maybe if I understood the business logic behind this, I could offer better advice.

Regards,

montubhardwaj
Specialist
Specialist

Hi,Let me know how you are calculating percentages i.e column(1)/column(2) or column(2)/column(1)

?

Regards,

Sharma

fernandotoledo
Partner - Specialist
Partner - Specialist

THE CORRECT CALCULATION IS


( [ACTUAL] - [PREVIOUS] ) / FABS([PREVIOUS])


WHERE ABS() IS THE ABSOLUTE VALUE FUNCTION

marcel_olmo
Partner Ambassador
Partner Ambassador
Author

Thank you guys. Your answers were very useful. It works fine.

Sorry for the delay because of the weekend.

See you around.