Forum Discussion

MickeLearnPBI's avatar
2 years ago
Solved

Problem with Switch and more than... Any ideas?

I have tried to do a dax with switch but does not seem to be working with value under och over.

 

Anyone have any ideas to do it better?

 

[Status] =
SWITCH(
TRUE(),
'table'[InvestigationID] = 0 && 'table'[DecisionID] > 0, "Notification One - investigation not opened",
'table'[DecisionID] = > 0, "Notification two - Decision not to open investigation",
'table'[InvestigationID] = > 0, "Actualizations processed",
'table'[InvestigationID] = 0, "New actualizations",
"Closed actualizations"
)

  • Anonymous's avatar
    Anonymous
    2 years ago

    Thanks for the reply from Jihwan_Kim , please allow me to provide another insight:

     

    Hi MickeLearnPBI ,

     

    Based on your description, the calculated column created, refer to the following:

    Status = 
    SWITCH(
        TRUE(),
        Notifications[InvestigationID] = 0 && Notifications[DecisionID] > 0, "Notification One - investigation not opened",
        Notifications[DecisionID] > 0, "Notification two - Decision not to open investigation",
        Notifications[InvestigationID] > 0, "Actualizations processed",
        Notifications[InvestigationID] = 0, "New actualizations",
        "Closed actualizations"
    )
    

     

    Best Regards,
    Adamk Kong

     

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

     

5 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Thanks for the reply from Jihwan_Kim , please allow me to provide another insight:

     

    Hi MickeLearnPBI ,

     

    Based on your description, the calculated column created, refer to the following:

    Status = 
    SWITCH(
        TRUE(),
        Notifications[InvestigationID] = 0 && Notifications[DecisionID] > 0, "Notification One - investigation not opened",
        Notifications[DecisionID] > 0, "Notification two - Decision not to open investigation",
        Notifications[InvestigationID] > 0, "Actualizations processed",
        Notifications[InvestigationID] = 0, "New actualizations",
        "Closed actualizations"
    )
    

     

    Best Regards,
    Adamk Kong

     

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

     

  • Hi, I guess you are trying to create a calculated column?
    Please try something like below whether it suits your requirement.

     

    [Status] =
    SWITCH (
        TRUE (),
        'table'[InvestigationID] = 0
            && 'table'[DecisionID] > 0, "Notification One - investigation not opened",
        'table'[DecisionID] >= 0, "Notification two - Decision not to open investigation",
        'table'[InvestigationID] >= 0, "Actualizations processed",
        'table'[InvestigationID] = 0, "New actualizations",
        "Closed actualizations"
    )
    
    • MickeLearnPBI's avatar
      MickeLearnPBI
      Icon for Helper I rankHelper I

      That almost worked. It seems that when I use this below i only get the two first results in the new column =
      'table'[InvestigationID] = 0
      && 'table'[DecisionID] > 0, "Notification One - investigation not opened",
      'table'[DecisionID] >= 0, "Notification two - Decision not to open investigation",

      [Status] =
      SWITCH (
          TRUE (),
          'table'[InvestigationID] = 0
              && 'table'[DecisionID] > 0, "Notification One - investigation not opened",
          'table'[DecisionID] >= 0, "Notification two - Decision not to open investigation",
          'table'[InvestigationID] >= 0, "Actualizations processed",
          'table'[InvestigationID] = 0, "New actualizations",
          "Closed actualizations"
      )

       

      Can i get all results in the same column somehow?

      • Jihwan_Kim's avatar
        Jihwan_Kim
        Icon for Super User rankSuper User

        Hi,

        I do not know well about your business logic, but please try writing down all conditions... something like below?

        [Status] =
        SWITCH (
            TRUE (),
            'table'[InvestigationID] = 0
                && 'table'[DecisionID] > 0, "Notification One - investigation not opened",
            'table'[InvestigationID] < 0
                && 'table'[DecisionID] >= 0, "Notification two - Decision not to open investigation",
            'table'[InvestigationID] >= 0
                && 'table'[DecisionID] < 0, "Actualizations processed",
            'table'[InvestigationID] = 0
                && 'table'[DecisionID] < 0, "New actualizations",
            "Closed actualizations"
        )