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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
DaveW
Advocate II
Advocate II

One table with 2 slicers changing 2 separate columns

I'm using PBI Report Server and using Direct Query Mode. 

I have a source table with rows of CostCentre Codes with a Version and a Total $ value

CCCode	Version	Total
123/123	1	120
123/123	2	240
123/123	3	360
123/123	4	480

I want to do a comparison between Versions of the CCCode with 2 independent Slicers. So 1st Slicer would select Version A and 2nd Slicer would select Version B.  The selection of the Version would return its relative Total value.

I would also like a calculation of the variance between Total A and Total B

 

CCCode	  Version A	Total A	   Version B	Total B	Variance (B-A)
123/123	  1	        120	   3            360     240	

I've built a report tha has 2 tables with a slicer for each but would like to merge the 2 tables into 1 table

I understand there are some limitations with measures runnig Direct Query mode.

2 ACCEPTED SOLUTIONS
OwenAuger
Super User
Super User

@DaveW 

 

I would recommend setting up your data model in a similar way to this article. In the linked article, the dimension in question was Date, but the same logic applies. You have one fact table but two copies of the dimension table in question.

 

I've uploaded a sample PBIX here.

 

First set up your tables/relationships like this, i.e. with additional Version A & Version B tables (should be possible from your DirectQuery source). Relationship between Version A & Version B should be inactive and 1:1.

 

 

Data modelData model

 

 

Then create measures like this:

Total A = 
SUM ( Data[Total] )

Total B = 
CALCULATE ( 
    [Total A],
    ALL ( 'Version A' ),
    USERELATIONSHIP ( 'Version A'[Version A], 'Version B'[Version B] )
)

Variance (B-A) = 
[Total B] - [Total A]

 

 

Report pageReport page

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

You're welcome 🙂
The reason for the inactive relationship is that we want only want one of the VersionA/VersionB filters applying at any time.

 

The model is set up so that the VersionA filter applies by default since it has an active relationship with the fact table. So in the Total A measure we get the sum of the Total column with the VersionA filter applied.

 

The VersionB filter is normally inactive, but is only activated within the Total B measure (as well as clearing the VersionA filter).

 

Cheers

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

View solution in original post

3 REPLIES 3
OwenAuger
Super User
Super User

@DaveW 

 

I would recommend setting up your data model in a similar way to this article. In the linked article, the dimension in question was Date, but the same logic applies. You have one fact table but two copies of the dimension table in question.

 

I've uploaded a sample PBIX here.

 

First set up your tables/relationships like this, i.e. with additional Version A & Version B tables (should be possible from your DirectQuery source). Relationship between Version A & Version B should be inactive and 1:1.

 

 

Data modelData model

 

 

Then create measures like this:

Total A = 
SUM ( Data[Total] )

Total B = 
CALCULATE ( 
    [Total A],
    ALL ( 'Version A' ),
    USERELATIONSHIP ( 'Version A'[Version A], 'Version B'[Version B] )
)

Variance (B-A) = 
[Total B] - [Total A]

 

 

Report pageReport page

 


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

This has worked. Thanks for that.  I was going to try to import 2 versions of the same table but it still wouldn't have been as agile as this solution

Can you confirm why the relationship between tables VersionA and VersionB is not active?

 

Cheers:)

You're welcome 🙂
The reason for the inactive relationship is that we want only want one of the VersionA/VersionB filters applying at any time.

 

The model is set up so that the VersionA filter applies by default since it has an active relationship with the fact table. So in the Total A measure we get the sum of the Total column with the VersionA filter applied.

 

The VersionB filter is normally inactive, but is only activated within the Total B measure (as well as clearing the VersionA filter).

 

Cheers

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
Twitter
LinkedIn

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.