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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
justin777
Frequent Visitor

Checking for divided by zero in Direct Query

Hi Guys, 

I can't seem to figure out how to properly solve the divided by zero. 

I have read some threads on the same subject but nothing works on my end. 
I already did check the box "Allow unrestricted measures in Direct Query Mode", restarted my computer to be sure that it is working but still not working. 

I tried

  • try [#"Var1"] / [#"Var2"]
  • if [#"Var1"] <> null then [#"Var1"] / [#"Var2"]
  • iferror 

still I get the error: This step results in a query that is not supported in DirectQuery Mode. 

Any choice I have? The only reason I'm using DirectQuery mode is that if I use Import Mode, weirdly enough this one view in my SQL Database always get a timeout error. Somewhere in between its getting an endless loop which is weird. 

3 REPLIES 3
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @justin777,

Based on my test, you can use the “if” function to divide the data with 0 that you want to show like the picture below, you can also use the “Divide” function in DAX with your data in report. https://msdn.microsoft.com/en-us/query-bi/dax/divide-function-dax

1.PNG

Regards,

Daniel He

 

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Are you using the DirectQuery method? Because in my case it is saying it doesn't support if when I put it

For me this solution works. Thanks!

 

Are you certain your not using the traditional (excel-like) IF-statement (Capitalized and with brackets), instead of the if- then-else (lowecase) variant?

Helpful resources

Announcements
May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.