Forum Discussion

KamilaOlek's avatar
KamilaOlek
New Member
10 years ago
Solved

division by zero

Hello,

 

I have encountered problem, that is killing me. I need to use Direct Query mode, which does not support IFERROR function.

 

I have several measures, that sometimes return error.

 

For example I have two columns:

NetValue

QuantityKG

 

QuantityKG is sometimes 0.

 

I need to make a measure: NetValue / QuantityKG. If it is an error I can have 0 calculated.

 

The measure would not be visible in a visual, because of division by zero, which I cannot easily solve with IFERROR statement.

 

I tried filtering values but it wouldn't help.

 

Do you have any idea how can I overcome this issue?

 

Thanks

 

  • KamilaOlek you can turn on feture to allow unrestricted measures in directquery which should then be able to use IFERROR function. You can go to File -> Options and settings -> DirectQuery.

     

     

  • What about just a simple IF statement?

     

    =IF([QuantityKG] = 0,0,DIVIDE([NetValue],[QuantityKG])

    You can also use DIVIDE function, probably a little cleaner:

     

    =DIVIDE([NetValue],[QuantityKG],0)

    DIVIDE will return the 3rd parameter as the value if a divide by zero occurs.

10 Replies