Forum Discussion
DIvided by Zero error when loading
- 2 years ago
You can try to pass in the 3rd parameter as 0 for the DIVIDE function. e.g.
DIVIDE(<numerator>, <denominator> [,<alternateresult>])z Payments Calculated Amount = SWITCH( TRUE() , [Line Amount Types] = "Inclusive" && [Type] = "ACCREC" , (([Line Amount]-[Tax Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total], 0 )) , [Line Amount Types] = "Exclusive" && [Type] = "ACCREC" , (([Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total], 0 )) , [Line Amount Types] = "NoTax" && [Type] = "ACCREC" , (([Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total], 0 )) , [Line Amount Types] = "Inclusive" && [Type] = "ACCPAY" , (0-([Line Amount]-[Tax Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total], 0 )) , [Line Amount Types] = "NoTax" || [Line Amount Types] = "NoTax" && [Type] = "ACCPAY" , ((0-[Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total], 0 )) , [Line Amount Types] = "Exclusive" || [Line Amount Types] = "NoTax" && [Type] = "ACCPAY" , ((0-[Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total], 0 )),0 ) - 2 years ago
Hi kristel_tulio ,
This issue you are having is occurring during the process of getting data using PowerQuery, not as a result of PowerBI or DAX.
It may be that the query is simple, making the query collapsed, which will be passed to the SQL database for calculation, and dividing by 0 inside the SQL database will report an error.
An easy way to do this is to use the "Detect Data type" feature to change the datatype of all fields immediately after the navigation step in PowerQuery, so that the query does not collapse, the calculations are handled in PowerQuery, and PowerQuery does not report an error when dividing by zero.
Or you can use try ... otherwise ... statement to protect the division operation, for example:
Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !
Thank you~
Here is the error message
Hi kristel_tulio ,
This issue you are having is occurring during the process of getting data using PowerQuery, not as a result of PowerBI or DAX.
It may be that the query is simple, making the query collapsed, which will be passed to the SQL database for calculation, and dividing by 0 inside the SQL database will report an error.
An easy way to do this is to use the "Detect Data type" feature to change the datatype of all fields immediately after the navigation step in PowerQuery, so that the query does not collapse, the calculations are handled in PowerQuery, and PowerQuery does not report an error when dividing by zero.
Or you can use try ... otherwise ... statement to protect the division operation, for example:
Did I answer your question? If yes, pls mark my post as a solution and appreciate your Kudos !
Thank you~