Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

calculated column logic is not as expected.

LegendCategory = SWITCH(     TRUE(),     SELECTEDVALUE(Reporter[Reporter Order]) = 0, 'DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Import Zone],     SELECTEDVALUE(Reporter[Reporter Order]) = 1, 'DMT_GTA ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi Anonymous 

     

    Thank you very much Fowmy and FreemanZ for your prompt reply.

     

    For this problem, I recommend that you create a measure instead of calculating a column.

     

    The measures are dynamically changed based on the selection of the slicer, which is more consistent with usage habits. Also, I have made changes to your code as follows:

     

     

    LegendCategory = 
    IF(
        ISFILTERED('Reporter'[Reporter Order]),
        SWITCH(
            TRUE(),
            SELECTEDVALUE(Reporter[Reporter Order]) = 0, SELECTEDVALUE('DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Import Zone]),
            SELECTEDVALUE(Reporter[Reporter Order]) = 1, SELECTEDVALUE('DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Export Zone]),
            SELECTEDVALUE(Reporter[Reporter Order]) = 2, SELECTEDVALUE('DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Import Zone]),
            SELECTEDVALUE(Reporter[Reporter Order]) = 3, SELECTEDVALUE('DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Export Zone])
        ),
        "Please select a value"
    )

     

     

     

    Regards,

    Nono Chen

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