Forum Discussion

rubulsahu's avatar
rubulsahu
Frequent Visitor
2 years ago

Need help to create below DAX command

HI All,

 

I am very few to PowerBi and still catching up with its various commands. I have a complex requirement from business whereI have to calculate a new column using the formula defined in the image. First I  have to filter on status and then based on values calculate the Assessmrt outcome value. Its very tricky for me and hoping someone could guide me in the right direction.

5 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    rubulsahu Use a SWITCH(TRUE()...) statement like:

     

    Column = 
      SWITCH(TRUE(),
        [Global Assessment Outcome] <> BLANK(), [Global Assessment Outcome],
        [Triage Outcome] <> "Select One", [Triage Outcome],
        [PreImpAss Outcome] = "SELECT ONE", "NA",
        [PreImpAss Outcome]
      )

     

    • rubulsahu's avatar
      rubulsahu
      Frequent Visitor

      Hi Greg_Deckler Thankyou so much for the prompt response. But I have to first filter Status Value(col 1) . How I can include If with Switch? 

      When Status is cancelled then Cancelled

      When Status in(

      Administrative Update

      Global Cross-functional Impact Assessment in Progress

      Global Implementation Ongoing

      Local Implementation Only (no Global Impact)

      Local Implementation (Global Implementation Complete)

      Completed PV Policy Activities

      ) then

      Switch

      • Greg_Deckler's avatar
        Greg_Deckler
        Community Champion

        rubulsahu Should be simple:

         

        Column = 
          SWITCH(TRUE(),
            [Status] = "Cancelled", "Cancelled",
            [Global Assessment Outcome] <> BLANK(), [Global Assessment Outcome],
            [Triage Outcome] <> "Select One", [Triage Outcome],
            [PreImpAss Outcome] = "SELECT ONE", "NA",
            [PreImpAss Outcome]
          )

        This assumes that all other values for Status should go through the rest of the evaluation process. If that is not the case then you could do this:

         

         

        SWITCH(TRUE(),
          [Status] = "Cancelled" || [Status] = "Administrative Update" || [Status] = "Global Cross-functional Impact Assessment in Progress", // add more or statements as necessary
            SWITCH(TRUE(),
               [Status] = "Cancelled", "Cancelled",
               [Global Assessment Outcome] <> BLANK(), [Global Assessment Outcome],
               [Triage Outcome] <> "Select One", [Triage Outcome],
               [PreImpAss Outcome] = "SELECT ONE", "NA",
               [PreImpAss Outcome]
            ),
          "Something else"
        )​