Power BI: Filter Table by Switch Measure

32 views Asked by At

Hello I am using the following code to generate separate order buckets depending in the timing of the invoice and the date selected on the screen. I want to display a table of all orders on the page and then filter it by clicking a donut chart that displays all the buckets. Here are the measures that I am using:

Time Frame (Same Day) =CALCULATE([Sales Credit Master],AND(SAP_Order_Export[Sales Credit Timeframe]="Same Day",SELECTEDVALUE(SAP_Order_Export[Invoice DateMaster])=SAP_Order_Export[Sales Order Date]))
 
Time Frame (Historical) = CALCULATE([Sales Credit Master], AND(SAP_Order_Export[Sales Credit Timeframe]="Historical",SELECTEDVALUE(SAP_Order_Export[InvoiceDateMaster])>SAP_Order_Export[Sales Order Date]))

Time Frame (Open) = CALCULATE([Total Open (DSR Page)],AND(SELECTEDVALUE(SAP_Order_Export[Invoice Date Master])=SAP_Order_Export[Sales Order Date],SAP_Order_Export[Invoice Date Master]=blank()))

Time Frame (Future Revenue) = CALCULATE([Total Booked],ALL(SAP_Order_Export),AND(SELECTEDVALUE('Invoice App Date'[Date])<SAP_Order_Export[Invoice Date Master],SELECTEDVALUE('Invoice App Date'[Date])=SAP_Order_Export[Sales Order Date]))

I am displaying these measures in a donut chart that is shown in the attached image. I want to be able to filter a table of all orders by clicking on the donut chart. There must be a way to achieve this using "SUMMARIZE" or a similar function. Any suggestions would be greatly appreciated. I tried using a calculated column to create the buckets but could not because some of them use SELECTEDVALUE function.

enter image description here

1

There are 1 answers

0
Amira Bedhiafi On

I would go for creating a helper table :

Time Frame Categories = DATATABLE(
    "Time Frame", STRING,
    {
        {"Same Day"},
        {"Historical"},
        {"Open"},
        {"Future Revenue"}
    }
)

and you need to update the measures to respond to the selected time frame in it like below (I am providing the code for only 1 measure, the remaining you can do the same way) :

Time Frame (Same Day) = 
VAR SelectedTimeFrame = SELECTEDVALUE('Time Frame Categories'[Time Frame])
RETURN
IF(
    SelectedTimeFrame = "Same Day",
    CALCULATE(
        [Sales Credit Master],
        AND(
            SAP_Order_Export[Sales Credit Timeframe]="Same Day",
            SELECTEDVALUE(SAP_Order_Export[Invoice DateMaster])=SAP_Order_Export[Sales Order Date]
        )
    ),
    BLANK()
)

For a dynamic filter behaviour,use TREATAS in your measure.