Forum Discussion
One table with 2 slicers changing 2 separate columns
- 7 years ago
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 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 page
- 7 years ago
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
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 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 page
- DaveW7 years ago
Advocate II
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:)
- OwenAuger7 years ago
Super User
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