Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

How to get multiple results from SWITCH() function?

Hi All,   I am trying to output multiple results depending on the selected field.    These multiple results are an average, an upper bound and lower bound standard deviation: This works we...
  • zaza's avatar
    5 years ago

    The logic behind switch is this:

     

    if value equals X than "show me this", otherwise

    if value equals Y than "show me that", ...

     

    What you've wrote is this:

     

    if value equals X than "show me this", otherwise

    if value equals X than "show me that", ...

     

    However this cannot work since X cannot equal 2 conditions at the same time. You cannot have "CRT" 3 times and "% Share Volume" also 3 times.

     

    You need to create 3 separate switch functions:

     

    Upper Bound = 
    switch(
        SELECTEDVALUE(Range[Metric]),
            "CRT", 'Verizon Call Reason'[YMax CRT],
            "% Share Volume",'Verizon Call Reason'[YMax V%],
            0
    )
    Lower Bound = 
    switch(
        SELECTEDVALUE(Range[Metric]),
            "CRT", 'Verizon Call Reason'[YMin CRT],
            "% Share Volume", 'Verizon Call Reason'[YMin V%],
            0
    )
    Average = 
    switch(
        SELECTEDVALUE(Range[Metric]),
            "CRT", 'Verizon Call Reason'[Avg CRT],
            "% Share Volume", 'Verizon Call Reason'[Avg V%],
            0
    )