Forum Discussion
Query Regarding Dynamic Queries
- 1 year ago
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:Basically whenever it finds a measure named Revenue it swaps it with UC_Revenue when you have UC selected. And similar for PC.
Hope it helps! - 1 year ago
- ✅ 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.
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.