The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
Date | Area | Continent | Sold |
2025-12-28 | Central | Asia | 5 |
2025-12-28 | East | Asia | 6 |
2025-12-28 | West | Asia | 8 |
2025-12-28 | Central | America | 4 |
2025-12-28 | East | America | 4 |
2025-12-29 | Central | Asia | 7 |
2025-12-29 | East | Asia | 7 |
America | America | Asia | Asia | Asia | |
Central | East | Central | East | West | |
America + Central | Blank | 0 | Blank | Blank | Blank |
America + East | 0 | Blank | Blank | Blank | Blank |
Asia + Central | Blank | Blank | Blank | -1 | -3 |
Asia + East | Blank | Blank | 1 | Blank | -2 |
Asia + West | Blank | Blank | 3 | 2 | Blank |
Solved! Go to Solution.
Use a 2-dimension (row/column) setup and one measure.
1) Create a location dim and a copy (for columns)
DimLoc =
DISTINCT ( SELECTCOLUMNS ( Fact, "Continent", Fact[Continent], "Area", Fact[Area] ) )
DimLoc_Col = DimLoc
Relate Fact[Continent],[Area] → DimLoc[...] and Fact[...] → DimLoc_Col[...] (both many-to-one, active). Keep your Date table slicer linked to Fact.
2) Measure for the matrix
Put DimLoc on Rows and DimLoc_Col on Columns, then use:
Diff :=
VAR sameContinent =
SELECTEDVALUE(DimLoc[Continent]) = SELECTEDVALUE(DimLoc_Col[Continent])
VAR sameArea =
SELECTEDVALUE(DimLoc[Area]) = SELECTEDVALUE(DimLoc_Col[Area])
RETURN
IF (
NOT sameContinent, BLANK(),
IF (
sameArea, BLANK(),
VAR rowSold =
CALCULATE ( SUM ( Fact[Sold] ), ALL ( DimLoc_Col ) ) -- only row loc
VAR colSold =
CALCULATE ( SUM ( Fact[Sold] ), ALL ( DimLoc ) ) -- only column loc
RETURN rowSold - colSold
)
)
This returns blank when continents differ or areas match; otherwise it shows the difference for the selected date.
Hi @FPP
create a table (*this table shouldn't have any relation with your data table*) :
Use a Matrix visual:
Rows → from Table2
Columns → from your Data table
Values → the measure you created
Turn off row and column subtotals
Use a 2-dimension (row/column) setup and one measure.
1) Create a location dim and a copy (for columns)
DimLoc =
DISTINCT ( SELECTCOLUMNS ( Fact, "Continent", Fact[Continent], "Area", Fact[Area] ) )
DimLoc_Col = DimLoc
Relate Fact[Continent],[Area] → DimLoc[...] and Fact[...] → DimLoc_Col[...] (both many-to-one, active). Keep your Date table slicer linked to Fact.
2) Measure for the matrix
Put DimLoc on Rows and DimLoc_Col on Columns, then use:
Diff :=
VAR sameContinent =
SELECTEDVALUE(DimLoc[Continent]) = SELECTEDVALUE(DimLoc_Col[Continent])
VAR sameArea =
SELECTEDVALUE(DimLoc[Area]) = SELECTEDVALUE(DimLoc_Col[Area])
RETURN
IF (
NOT sameContinent, BLANK(),
IF (
sameArea, BLANK(),
VAR rowSold =
CALCULATE ( SUM ( Fact[Sold] ), ALL ( DimLoc_Col ) ) -- only row loc
VAR colSold =
CALCULATE ( SUM ( Fact[Sold] ), ALL ( DimLoc ) ) -- only column loc
RETURN rowSold - colSold
)
)
This returns blank when continents differ or areas match; otherwise it shows the difference for the selected date.
@FPP You will need to create an urelated table like the following:
Table 2 = SELECTCOLUMNS( 'Table', "Continent", [Continent], "Area", [Area] )
Use this as either the rows or columns in the matrix and use the Country and Area from the original table as the other (row/column). You can then use a measure like the following:
Measure =
VAR _Continent1 = MAX( 'Table'[Continent] )
VAR _Area1 = MAX( 'Table'[Area] )
VAR _Continent2 = MAX( 'Table 2'[Continent] )
VAR _Area2 = MAX( 'Table 2'[Area] )
VAR _Date = MAX( 'Table'[Date] )
VAR _Return =
SWITCH( TRUE(),
_Continent1 <> _Continent2, BLANK(),
_Area1 = _Area2, BLANK(),
SUM( 'Table'[Sold] ) - CALCULATE( SUM( 'Table'[Sold] ), FILTER( ALL( 'Table'), 'Table'[Date] = _Date && 'Table'[Continent] = _Continent2 && 'Table'[Area] = _Area2 ) )
)
RETURN
_Return
User | Count |
---|---|
14 | |
12 | |
7 | |
6 | |
5 |
User | Count |
---|---|
28 | |
18 | |
13 | |
7 | |
5 |