Forum Discussion

dcheng029's avatar
dcheng029
Helper II
2 years ago
Solved

How to use switch function to return 3 results?

Hi team,   I am currently working with below table data columns: - Category Type: A or B - Calendar Days: numerical between 1 to max - Business Days: numerical between 1 to max - Identity 1: nu...
  • Wilson_'s avatar
    Wilson_
    2 years ago

    dcheng029,

     

    You were on the right path with SWITCH. The SWITCH ( TRUE() ) pattern is probably the most intuitive way to work with SWITCH, especially if you have multiple criteria within your different conditions.

     

    Try:

    SWITCH (
        TRUE(),
        Table[Category Type] = "A" && Table[Calendar Days] <= 30 && Table[Identity 1] > 0, "YES",
        Table[Category Type] = "A" && Table[Calendar Days] <= 45 && Table[Identity 2] > 0, "YES",
        Table[Category Type] = "B" && Table[Business Days] <= 16, "YES",
        Table[Identity 1] > 0 && Table[Identity 2] > 0 && Table[Category Type] = "A" && Table[Calendar Days] <= 45, "YES",
        "NO"
    )


    ----------------------------------
    If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

     

    P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.