Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.
Hi, I would like to ask how to fix the Divided by zero error when loading the report? I suspect this calculation is the reason. I hope you can help me with it. Thank you
z Payments Calculated Amount =
SWITCH( TRUE(),
[Line Amount Types] = "Inclusive" && [Type] = "ACCREC",
(([Line Amount]-[Tax Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total] )),
[Line Amount Types] = "Exclusive" && [Type] = "ACCREC",
(([Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total] )),
[Line Amount Types] = "NoTax" && [Type] = "ACCREC",
(([Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total] )),
[Line Amount Types] = "Inclusive" && [Type] = "ACCPAY",
(0-([Line Amount]-[Tax Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total] )),
[Line Amount Types] = "NoTax" || [Line Amount Types] = "NoTax" && [Type] = "ACCPAY",
((0-[Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total] )),
[Line Amount Types] = "Exclusive" || [Line Amount Types] = "NoTax" && [Type] = "ACCPAY",
((0-[Line Amount]) * DIVIDE( [PaymentAmount] , [Invoice Total] )),
0)
Solved! Go to Solution.
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
)
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~
Can you provide more details, such as error messages?
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~
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
)
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the September 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
13 | |
11 | |
10 | |
10 |