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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
senescence
Frequent Visitor

How to calculate difference between two tiles with different slicers dynamically?

Hi,

 

I suspect there is no solution to this but here goes:

 

I have data in a table as follows:

 

High, 01/09/17

High, 01/09/17

Medium, 01/09/17

Low, 01/09/17

High, 02/09/17

Medium, 02/09/17

Medium, 02/09/17

Low, 02/09/17

High, 03/09/17

Medium, 03/09/17

Low, 03/09/17

Low, 03/09/17

 

In my report I have two tables and two slicers (that only work on one table each). So a user selecting 01/09/17 in Slicer A and 03/09/17 in Slicer B gets:

 

Table A:

 

High, 2

Medium, 1

Low, 1

 

Table B:

 

High, 1

Medium, 1

Low, 2

 

What I want is to show the difference between these two tiles:

 

Difference:

 

High, -1

Medium, 0

Low, 1

 

It is similar to this problem but the solution here doesn't allow the user make changes using the slicers as the filter is apllied in the query editor:

 

https://community.powerbi.com/t5/Desktop/How-to-calculate-difference-after-different-filter-settings...

 

I'm new to Power BI so any help appreciated.

 

Thanks.

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @senescence,

 

To achieve this requirement, the date column added into two slicers have to come from two unrelated tables. So, in this scenario, you should create two calendar tables:

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

Calendar Date 2 = CALENDAR(MIN('Test'[Date]),MAX('Test'[Date]))

Then, create three measures like below:

Count1 = CALCULATE(COUNT('Test'[Date]),FILTER('Test','Test'[Date]=MAX('Calendar Date'[Date])))
Count2 = CALCULATE(COUNT('Test'[Date]),FILTER('Test','Test'[Date]=MAX('Calendar Date 2'[Date])))

diff = [Count2]-[Count1]

Add corresponding columns and measures into table visual. Notice that the date in slicer1 comes from 'Calendar Date', while date in slicer2 should come from 'Calendar Date 2'.

3.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @senescence,

 

To achieve this requirement, the date column added into two slicers have to come from two unrelated tables. So, in this scenario, you should create two calendar tables:

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

Calendar Date 2 = CALENDAR(MIN('Test'[Date]),MAX('Test'[Date]))

Then, create three measures like below:

Count1 = CALCULATE(COUNT('Test'[Date]),FILTER('Test','Test'[Date]=MAX('Calendar Date'[Date])))
Count2 = CALCULATE(COUNT('Test'[Date]),FILTER('Test','Test'[Date]=MAX('Calendar Date 2'[Date])))

diff = [Count2]-[Count1]

Add corresponding columns and measures into table visual. Notice that the date in slicer1 comes from 'Calendar Date', while date in slicer2 should come from 'Calendar Date 2'.

3.PNG

 

Best regards,
Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

This worked perfectly and makes complete sense - thanks for your help.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.