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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
BjoernSchaefer
Helper II
Helper II

Strange behaviour of SWITCH-Function

Hello Community,

 

i was just wondering if someone is able to tell me what i'm doing wrong in that Formula:

BjoernSchaefer_0-1636365019737.png

 

ID 8 appears twice but ID 12 is missing. Hints or Ideas are appreciated. Thank everyone very much in advance.

 

Best regards

 

Björn

 

 

 

 

1 ACCEPTED SOLUTION

Hi @BjoernSchaefer ,

 

enter data:

vchenwuzmsft_0-1636960123797.png

import model . It is a mode that connect to the file or dateset.(other two modes : Direct query and Live connection)

vchenwuzmsft_2-1636960363248.png

 

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-use-directquery#how-to-connect-using-... 

 

Best Regards

Community Support Team _ chenwu zhu

View solution in original post

6 REPLIES 6
v-chenwuz-msft
Community Support
Community Support

Hi @BjoernSchaefer ,

 

Another way. 

Change the type to Fix decimal number, the table created via GENERATESERIES(0,1,0.05) will also return the right result.

vchenwuzmsft_0-1637633040131.png

 

Best Regards

Community Support Team _ chenwu zhu

BjoernSchaefer
Helper II
Helper II

Here's the Table Code: Cluster = GENERATESERIES(0,1,0.05)
 
Syntax for the ID:

Cluster ID =
SWITCH(
TRUE(), 'Cluster'[Value]>=0&&'Cluster'[Value]<0.05,1,
'Cluster'[Value]>=0.05&&'Cluster'[Value]<0.1,2,
'Cluster'[Value]>=0.1&&'Cluster'[Value]<0.15,3,
'Cluster'[Value]>=0.15&&'Cluster'[Value]<0.2,4,
'Cluster'[Value]>=0.2&&'Cluster'[Value]<0.25,5,
'Cluster'[Value]>=0.25&&'Cluster'[Value]<0.3,6,
'Cluster'[Value]>=0.3&&'Cluster'[Value]<0.35,7,
'Cluster'[Value]>=0.35&&'Cluster'[Value]<0.4,8,
'Cluster'[Value]>=0.4&&'Cluster'[Value]<0.45,9,
'Cluster'[Value]>=0.45&&'Cluster'[Value]<0.5,10,
'Cluster'[Value]>=0.5&&'Cluster'[Value]<0.55,11,
'Cluster'[Value]>=0.55&&'Cluster'[Value]<0.6,12,
'Cluster'[Value]>=0.6&&'Cluster'[Value]<0.65,13,
'Cluster'[Value]>=0.65&&'Cluster'[Value]<0.7,14,
'Cluster'[Value]>=0.7&&'Cluster'[Value]<0.75,15,
'Cluster'[Value]>=0.75&&'Cluster'[Value]<0.8,16,
'Cluster'[Value]>=0.8&&'Cluster'[Value]<0.85,17,
'Cluster'[Value]>=0.85&&'Cluster'[Value]<0.9,18,
'Cluster'[Value]>=0.9&&'Cluster'[Value]<0.95,19,
'Cluster'[Value]>=0.95,20)

Hi @BjoernSchaefer,

 

I tested this and it was a bug. I have submitted this bug and I will let you know if there are any updates.
If you use enter date or import mode, the result of switch() will be correct.

 

Best Regards

Community Support Team _ chenwu zhu

 

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

 

Hello @v-chenwuz-msft ,

 

thank you for the information. 

 

I'm not sure what you mean when you wrote "If you use enter date or import mode, the result of switch() will be correct." Could you please explain?

 

Regards

 

Björn

Hi @BjoernSchaefer ,

 

enter data:

vchenwuzmsft_0-1636960123797.png

import model . It is a mode that connect to the file or dateset.(other two modes : Direct query and Live connection)

vchenwuzmsft_2-1636960363248.png

 

https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-use-directquery#how-to-connect-using-... 

 

Best Regards

Community Support Team _ chenwu zhu

Hi @v-chenwuz-msft ,

 

that was too obvious. Thank you very much. It works.

 

Best regards

 

Björn

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors