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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
ANVS
Regular Visitor

Query Regarding Dynamic Queries

Hello There,

I have scenario which is as follows:

The requirement is that - There is a slicer which contains a dropdown consisting of values PC and UC.

In the Data Pane I have PC Calculated measures and UC calculated measures seperately around 50 to 60 measures for each.

So, now the requirement is that When I select UC from the Slicer Dropdown all my visuals, charts, KPI's, tables should take values from UC Calculated measures present in the data pane, and when I select PC from slicer dropdown all my visuals, KPI's, Tables, charts should take values from PC calculated measures present in the data pane.

So, how do I achieve this requirement in Power BI without much much complexity.

Appreciate an quick response.

2 ACCEPTED SOLUTIONS
alish_b
Resolver III
Resolver III

Hey @ANVS ,

 

You could set up calculation groups with two calculation items for PC and UC. Then, the calculation items you could switch between measure names as follows:

PC = SWITCH(
    SELECTEDMEASURENAME(),
    "Revenue", [PC_Revenue],
    "Profit", [PC_Profit],
    "Units", [PC_Units],
    "Margin", [PC_Margin],
    "Avg Order Value", [PC_AvgOrderValue],
    BLANK()
)

Well here is where you would keep the 50-60 measures you have for PC and in another calculation item for UC you would keep the ones for UC. Common measures will share the same name. For the sake of clean implementation, you could add generic measures like Revenue = BLANK() and the calculation groups will handle replacing that with the required value when you make the calculation group choice. Here are some screenshots of a sample implementation:
alish_b_1-1756884046489.png

 

alish_b_2-1756884119601.png

 

alish_b_4-1756884346773.png

Basically whenever it finds a measure named Revenue it swaps it with UC_Revenue when you have UC selected. And similar for PC.

alish_b_5-1756884453619.png


Hope it helps!





 


 

View solution in original post

Shahid12523
Community Champion
Community Champion

- Create a disconnected table with values PC and UC
- Add a slicer using that table
- Write a dynamic measure like this:


Dynamic_Measure =
SWITCH(
SELECTEDVALUE(MeasureSelector[Type]),
"PC", [PC_Measure],
"UC", [UC_Measure]
)


Use Dynamic_Measure in all visuals instead of separate PC/UC measures. Clean, scalable, and no duplication needed.

Shahed Shaikh

View solution in original post

9 REPLIES 9
V-yubandi-msft
Community Support
Community Support

If the response was helpful and resolved your issue, kindly consider marking it as the Accepted Solution. This makes it easier for other community members to discover useful answers and benefits everyone facing similar challenges.

 

Thank you

V-yubandi-msft
Community Support
Community Support

Hi @ANVS ,
Could you let us know if your issue has been resolved or if you are still experiencing difficulties? Your feedback is valuable to the community and can help others facing similar problems.

Yes, Resolved

Thank you for confirming, @ANVS . If you can, please mark the response that resolved your issue. This will help others in the community find solutions more easily.

Regards,
Yugandhar.

Shahid12523
Community Champion
Community Champion

- Create a disconnected table with values PC and UC
- Add a slicer using that table
- Write a dynamic measure like this:


Dynamic_Measure =
SWITCH(
SELECTEDVALUE(MeasureSelector[Type]),
"PC", [PC_Measure],
"UC", [UC_Measure]
)


Use Dynamic_Measure in all visuals instead of separate PC/UC measures. Clean, scalable, and no duplication needed.

Shahed Shaikh

Thanks for this @Shahid12523 .

Have a query here again:

Dont we need to create seperate dynamic measures for each measure in UC and PC calculations?

or only the Single measure which you have given works?

If you want to avoid having to create and manage 50,60 dynamic measures, the calculation group approach mentioned earlier is recommended. Calculation groups allow you to use generic measures in your visuals, and the group will automatically switch between PC and UC versions, making the solution more scalable.

 

regards,
Yugandhar.

alish_b
Resolver III
Resolver III

Hey @ANVS ,

 

You could set up calculation groups with two calculation items for PC and UC. Then, the calculation items you could switch between measure names as follows:

PC = SWITCH(
    SELECTEDMEASURENAME(),
    "Revenue", [PC_Revenue],
    "Profit", [PC_Profit],
    "Units", [PC_Units],
    "Margin", [PC_Margin],
    "Avg Order Value", [PC_AvgOrderValue],
    BLANK()
)

Well here is where you would keep the 50-60 measures you have for PC and in another calculation item for UC you would keep the ones for UC. Common measures will share the same name. For the sake of clean implementation, you could add generic measures like Revenue = BLANK() and the calculation groups will handle replacing that with the required value when you make the calculation group choice. Here are some screenshots of a sample implementation:
alish_b_1-1756884046489.png

 

alish_b_2-1756884119601.png

 

alish_b_4-1756884346773.png

Basically whenever it finds a measure named Revenue it swaps it with UC_Revenue when you have UC selected. And similar for PC.

alish_b_5-1756884453619.png


Hope it helps!





 


 

ChielFaber
Solution Supplier
Solution Supplier

You might want to look into the usage of PowerBI bookmarks to create buttons to easily switch between the two options: 

An example video:
https://www.youtube.com/watch?v=_HTF7Ph7Eqc

Information:

https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-bookmarks 


[Tip] Keep CALM and DAX on.
[Solved?] Hit “Accept as Solution” and leave a Kudos.
[About] Chiel | SuperUser (2023–2) |

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors