Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hello,
I would like to know if it is possible to compare 2 values based on 2 different segments, but both segments are based on the same table.
Let me explain.
I have a simple model, with 2 tables in a 1 to * relationship (dim to fact) :
- Dim1, with information on vehicules (VehiculeNumber, VehiculeSeries)
- Faits1, with vehicule performances (VehiculeNumber, Litres, Km...)
Let's say, I would like to be able to compare performances between specific Series.
I want to be able to select a "reference Series" and a "compare with Series", so I add 2 segments, with the same column, but I deactivate interactions between them so I can view the entire series.
I need to add a measure that would calculate the sum of Litres from one segment - the sum of Litres from the other segment.
I can then add this measure to a single card visual for example.
To put it "simply" :
- Value1 = Sum of Litres from Segment1
- Value2 = Sum of Litres from Segment2
- Variation = Value1 - Value2
Problem is, since Segment1 and Segment2 are based on the same column (Dim1[Series]), any way I tried was unsuccessful.
In image :
I know of a way to get what i want, by just adding a second Dim table similar to the first one, and then just using Series from both Dim tables into different segments. But this method seems terrible when your model gets bigger, as I would need to duplicate certain tables for this sole purpose.
I thought of using ALL, ALLEXCEPT, or ALLSELECTED, but it doesn't seem to work. I have also tried adding a second, identical "Series" column in the Dim1 table, and changed the segments accordingly, but still no work around.
So, does anyone know if it is possible to do this with DAX and measures ? Or do I really need to have different tables ?
Solved! Go to Solution.
You would need to have 2 tables. You could create the second one like
Series 2 = ALLNOBLANKROW( DIM_1[Series] )
Don't create a relationship from this table to any others, just use it in your slicer and then you can create a measure like
Variation =
VAR Val1 =
SUM ( Faits_1[Litres] )
VAR Val2 =
CALCULATE (
SUM ( Faits_1[Litres] ),
TREATAS ( VALUES ( Series2[Series] ), DIM_1[Series] )
)
RETURN
Val1 - Val2
You would need to have 2 tables. You could create the second one like
Series 2 = ALLNOBLANKROW( DIM_1[Series] )
Don't create a relationship from this table to any others, just use it in your slicer and then you can create a measure like
Variation =
VAR Val1 =
SUM ( Faits_1[Litres] )
VAR Val2 =
CALCULATE (
SUM ( Faits_1[Litres] ),
TREATAS ( VALUES ( Series2[Series] ), DIM_1[Series] )
)
RETURN
Val1 - Val2
Okay, thank you, this works great. Too bad we can't do this we just one table, but still cool to be able to have this option.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
88 | |
86 | |
68 | |
51 | |
32 |
User | Count |
---|---|
126 | |
112 | |
72 | |
64 | |
46 |