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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

v-jingzhan-msft

How to use the synchronous slicer with drillthrough to dynamically calculate the sum of Qty

Scenario:

In this post, we will use Sync slicer with the drill-through feature to dynamically calculate data over a period of time.

Let's say we have a sales report with multiple pages: one for overall sales, another for product categories, and a third for regional sales. On the page for overall sales, we want to analyze sales data for a specific month, so set a slicer for the month name (for example, January, February, and so on). On other pages we want to see some more sales data by drilling through from the overall sales page. When drilling through from the overall sales page to the product category or regional sales page, we hope to see the sales data between the drill point date and the slicer date, instead of only the data on the drill point date by default. To deal with that, using the sync slicer to apply the Month slicer to all pages may be an option. Let’s go to the following sections for details.

 

Expected Result:

I have some sample data as below.

vjingzhanmsft_0-1718606996314.png

 

I have a line chart and a slicer on the page 1 (page for overall sales). This line chart has the date column as the X-axis and QTY as the Y-axis. The slicer field is the year and month. I can select months in the slicer and see corresponding QTY data displayed in the line chart.

vjingzhanmsft_0-1718608880322.png

 

Next, drill through at a date point (e.g. 4/1/2024) in the line chart to the page 2:

vjingzhanmsft_2-1718606996316.png

 

I set up a table visual on the page 2. In addition to displaying the sales QTY of the drill through date (e.g. 45 in below image), I also want to have the sum of QTYs between the smallest date in the slicer-selected month on the previous page and the date of the drill through, e.g. 155 in the image (155=30+40+15+25+45).

vjingzhanmsft_1-1718608929776.png

 

How:

Create a date table based on the date columns of the original table, and then use the date columns of this date table in the slicer to create a synchronized slicer.

 

1. Use the following DAX expression to create a Calendar table:

 

 

 

Calendar table = CALENDAR ( MIN ( 'Table'[Date] ), MAX ( 'Table'[Date] ) )

 

 

 

vjingzhanmsft_2-1718609034504.png

 

2. Create a relationship between two tables:

vjingzhanmsft_3-1718609070744.png

 

3. Use the Date column of the new table in the page1 report page:

vjingzhanmsft_0-1718609176036.png

 

4. Create a same slicer in page2 and enable the synchronized slicer feature:

vjingzhanmsft_1-1718609201149.png

 

5. Set the drill through field to Qty:

vjingzhanmsft_2-1718609228454.png

 

6. Create two measures to get the drill through date and the minimum date in the year-month slicer's selected options:

 

 

DrillDay = CALCULATE ( MAX ( 'Table'[Date] ), ALLSELECTED ( 'Table'[Date] ) )
minday = CALCULATE ( MIN ( 'Calendar table'[Date] ), ALLSELECTED ( 'Calendar table'[Date] ) )

 

 

 

7. Create a measure using the following DAX expression to calculate the sum of QTY between two dates

 

 

Qtysum =
VAR _slicerday = [minday]
VAR _drillday = [DrillDay]
RETURN
    CALCULATE (
        SUM ( 'Table'[Qty] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Qty] ),
            'Table'[Date] >= _slicerday
                && 'Table'[Date] <= _drillday
        )
    )

 

 

 

8. Create a table visual object with drill through fields and Qtysum measure:

vjingzhanmsft_3-1718609337426.png

 

9. To hide the slicer of the drill through page:

vjingzhanmsft_4-1718609372811.png

 

Summary:

Drill through allows you to navigate from one page to another while preserving context, while synchronous slicers ensure consistent filtering across pages. We can use them at the same time to dynamically calculate data over time.

 

 

Author: Jianpeng Li

Reviewer: Ula and Kerry