Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
mloc1990
Helper I
Helper I

% difference between 2 negative numbers is a positive when it should be negative

Hi,

 

I'm hoping someone can help me. I have the below calculated column that compares the current field X to the same field 30 days ago Y to get a % difference

 

% diff 30 days ago = iferror(table[X]/table[Y],0)
 
The issue I'm having is if the current field of X is a bigger negative number than Y it gives me a positive value of % change instead of  negative.
 
e.g X -48613 and Y  -13694 it gives a positive % difference when it should be negative. Is there a way to correct this?
 
Thanks
1 ACCEPTED SOLUTION
Nathaniel_C
Super User
Super User

Hi @mloc1990 ,

 

 

% diff 30 days ago =IF(X<0 && Y<0 && X<Y,-1* iferror(table[X]/table[Y],0),iferror(table[X]/table[Y],0))

 

 

I would also use DIVIDE(), but basically wrap in an IF().  
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Nathaniel_C
Super User
Super User

Hi @mloc1990 ,

 

 

% diff 30 days ago =IF(X<0 && Y<0 && X<Y,-1* iferror(table[X]/table[Y],0),iferror(table[X]/table[Y],0))

 

 

I would also use DIVIDE(), but basically wrap in an IF().  
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi @Nathaniel_C 

 

This works great thanks for your help! I changed my formula a bit to the below and it appears to be doing what I need it too.

 

% diff 30 days ago = IF(X<0 && Y<0 && X<Y,-1* iferror(X/Y,0)+1,iferror(X/Y,0)-1)
 
Thanks!
 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.