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
pmadam
Helper II
Helper II

Help division error

Hi All,

 

I am trying to divide two text columns for a particluar dimension. So i get error when the numerator or denominator has blank value. I went forward and added if clause as below but i still get below error . 

 

Kindly sugest 

 

XY =
IF(ISBLANK([DSAM Amount]) && Not ISBLANK(VALUE([Customer Target])) <> "", 0 ,
(
([Customer Target] /
[DSAM Amount])))
 
 
division error.png

 

 

1 ACCEPTED SOLUTION

@pmadam Maybe:

XY =
IF(
  ISBLANK([DSAM Amount]) && Not(ISBLANK(VALUE([Customer Target]))), 
  0 ,
  [Customer Target] / [DSAM Amount]
)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

8 REPLIES 8
pmadam
Helper II
Helper II

Hi @Greg_Deckler ,

 

I get error. These measures are in text because when i added comma seperator, the measures were converted to type int to text.

 

Reply.png

@pmadam , Your measure should be divide( [Customer Target],[DSAM Amount],0)

@pmadam Maybe:

XY =
IF(
  ISBLANK([DSAM Amount]) && Not(ISBLANK(VALUE([Customer Target]))), 
  0 ,
  [Customer Target] / [DSAM Amount]
)

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@pmadam you have the wrong syntax for DIVIDE:

 

@Greg_Deckler 's code:  XY =DIVIDE( [Customer Target], [DSAM Amount], 0 )

 

Your code: XY =DIVIDE( [Customer Target] / [DSAM Amount] ,0 ). 

 

Even if you didn't throw an error with one of your "numbers" being empty, you are dividing by 0.

 

Hope this helps

David

Hi @pmadam ,

 

Are bot of your columns numeric which you are trying to divide.

DIVIDE is function that works on non-text values. If you think logically, how can you divide a text value by a numeric value.

 

Try modifying data type of your text column used in DIVIDE function to Numeric.

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Anonymous
Not applicable

@pmadam

Why are you outputting numbers as text? This is not how you do stuff correctly. If you want to format a number in a visual, please use the formatting options in the ribbon, not the FORMAT function.
Anonymous
Not applicable

The error says it all: you cannot compare bool values with text. Makes no sense... Here's how to use IF: IF( <logical_condition>, <case_for_True>, <case_for_False> ). You cannot do this True <> "". This comparison is not defined.
Greg_Deckler
Super User
Super User

@pmadam Use the DIVIDE function like this (get rid of the IF clause)

 

XY =DIVIDE([Customer Target],[DSAM Amount],0)
 
Third parameter is the one to return in case of divide by zero.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors