March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Solved! Go to Solution.
Hi @Samar1234
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.
@Samar1234 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"
)
Hi @Samar1234 ,
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
Hi @Samar1234
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.
@Samar1234
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:
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
hi @Samar1234 ,
calculated column/table is not supposed to response to the visual behaviors.
It is updated only if you refresh it manually.
Is there any alternate solution otherthan calculated measure.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
26 | |
21 | |
20 | |
14 | |
10 |