Forum Discussion

smjzahid's avatar
smjzahid
Icon for Helper V rankHelper V
3 years ago

Switch True throwing error (A table of multiple values was supplied)

I have measure like the one below, formatted as Currency

[PAIN / GAIN ALL] = CALCULATE([PAIN / GAIN],ALL(dimpartner))

 

[PAIN / GAIN] = CALCULATE(([Current Target]-[Current AFC]),FILTER(dimpartner,dimpartner[Partner Type]<>"Tier 2"))

 I am trying to add a SWITCH ( TRUE () logic to achieve the result, However I am getting below shown error.

 

I have below items in my table named 'dimpartner'[Partner] column  in DAX Studio it shows below values in partner column

EVALUATE(VALUES(dimpartner[Partner]))

Here is the error Power BI desktop throws and here is the Measure I have written

 

Alliance Members Pain / Gain Share with Switch 2 =
SWITCH (
    TRUE (),
    [PAIN / GAIN ALL] > 6000000
        && VALUES ( dimpartner[Partner] ) = "NetworkRail", [First 6M Gain to Network Rail],
    [PAIN / GAIN ALL] > 6000000
        && VALUES ( dimpartner[Partner] ) = "Murphys", [Percentage of Works Value],
    0
)

 

 

1 Reply

  • Samarth_18's avatar
    Samarth_18
    Icon for Community Champion rankCommunity Champion

    Hi smjzahid ,

     

    To give the correct answer other info is also required but in the meantime you can try below code:-

    Alliance Members Pain / Gain Share with Switch 2 =
    SWITCH (
        TRUE (),
        [PAIN / GAIN ALL] > 6000000
            && MAX ( dimpartner[Partner] ) = "NetworkRail", [First 6M Gain to Network Rail],
        [PAIN / GAIN ALL] > 6000000
            && MAX ( dimpartner[Partner] ) = "Murphys", [Percentage of Works Value],
        0
    )