Forum Discussion

ANVS's avatar
ANVS
Advocate II
11 months ago
Solved

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 ...
  • alish_b's avatar
    11 months 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!





     


     

  • Shahid12523's avatar
    11 months 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.