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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
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.
Please let me know how to overcome this.
Thanks.
Solved! Go to Solution.
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.
@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
)
Hi @Anonymous
what is the column Hour? is it calculated? are you sure it is exactly zero, not rounded decimal like 0.0000001?
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.
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.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 38 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |