Forum Discussion

BjoernSchaefer's avatar
4 years ago
Solved

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:

 

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

 

Best regards

 

Björn

 

 

 

 

6 Replies

  • 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)
    • v-chenwuz-msft's avatar
      v-chenwuz-msft
      Community Support

      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.

       

      • BjoernSchaefer's avatar
        BjoernSchaefer
        Helper II

        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

  • v-chenwuz-msft's avatar
    v-chenwuz-msft
    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.

     

    Best Regards

    Community Support Team _ chenwu zhu