Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

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 W_DMT_GTA_V_GTA_FCST_TON'[Export Zone],
    SELECTEDVALUE(Reporter[Reporter Order]) = 2, 'DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Import Zone],
    SELECTEDVALUE(Reporter[Reporter Order]) = 3, 'DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Export Zone],
    "Please select a value"
)
I dragged report order into slicer. If i select 0,1,2 or 3. It's only  compute once and remain static.
1 ACCEPTED SOLUTION
Anonymous
Not applicable

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:

 

vnuocmsft_0-1731463040336.png

 

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"
)

 

vnuocmsft_1-1731463113770.png

 

vnuocmsft_2-1731463136157.png

 

Regards,

Nono Chen

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

View solution in original post

6 REPLIES 6
AntrikshSharma
Super User
Super User

@Anonymous You can convert this into a Measure and provided the visual where this measure is used doesn't have more than 1 row in the DMT_GTA table.

 

LegendCategory =
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"
)

 

Ankur04
Resolver II
Resolver II

Hi @Anonymous ,

 

can you please help to understand the requirement and challenge you are facing with supporting input data and expect out data. 

 

A simple table with input data and expect result would help.

 

Thanks,

 

Ankur

Anonymous
Not applicable

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:

 

vnuocmsft_0-1731463040336.png

 

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"
)

 

vnuocmsft_1-1731463113770.png

 

vnuocmsft_2-1731463136157.png

 

Regards,

Nono Chen

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

Fowmy
Super User
Super User

@Anonymous 

What's your expected behavour? If you select a value from Reporter Order from a slicer and you need to make a calculation on a column then you need to provide a calculation like Sum(' 'DMT_GTA W_DMT_GTA_V_GTA_FCST_TON'[Import Zone]') not a column,  If you need to dynamically select a column based on selection, go for field paramerters: 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

FreemanZ
Super User
Super User

hi @Anonymous ,

 

calculated column/table is not supposed to response to the visual behaviors. 

It is updated only if you refresh it manually.

Anonymous
Not applicable

Is there any alternate solution otherthan calculated measure.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.