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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Switch/IF condition ignores zero

Hi Everyone,

 

While using DAX switch or if, condition ignores zero values.

 

Eg. In my case Im calculating Hour >=0 && Hour<4, it ignores zero values and executing values greater than zero.

 

I also tried Hour=0, even then it ignores the zero value.

 

Here is screenshot.

 

Untitled2.png

 

Please let me know how to overcome this.

 

Thanks.

 

1 ACCEPTED SOLUTION
dax
Community Support
Community Support

Hi @Anonymous , 

You also could refer to below calculated column for details.

Column = switch(TRUE(),ISBLANK('Table'[Hour]),0,'Table'[Hour]>=0 && 'Table'[Hour]<4,1,'Table'[Hour]>=4,0)

 You could refer to BLANK-is-caught-as-0-in-Columns  for details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

4 REPLIES 4
az38
Community Champion
Community Champion

@Anonymous 

sorry, I also see, you return 0 when Hour is plank. try to replace your conditions in switch like

SWITCH(TRUE(),
[Hour] >=0 && [Hour] < 4, 1,
0
)

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
az38
Community Champion
Community Champion

Hi @Anonymous 

what is the column Hour? is it calculated? are you sure it is exactly zero, not rounded decimal like 0.0000001?


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Hi @az38 , Thanks for response.

 

I understand the problem, in my condition I initially put criteria for blank() =0 (where 0 is taken as blank), so it has taken as zero, even if I try to change the criteria to multiple times it was taking into effect.

 

So I changed zero values to 1 in power query(Where zero values needs to taken into consideration not blank values) and calculated with switch condition with same expression it worked.

dax
Community Support
Community Support

Hi @Anonymous , 

You also could refer to below calculated column for details.

Column = switch(TRUE(),ISBLANK('Table'[Hour]),0,'Table'[Hour]>=0 && 'Table'[Hour]<4,1,'Table'[Hour]>=4,0)

 You could refer to BLANK-is-caught-as-0-in-Columns  for details.

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.