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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Anonymous
Not applicable

Adding a total matrix from a different data set

I have two HR data sets below; one is data of all employees by department and categories (total population) and the second is the data set of employees that left and their leave reason (departure data).

There is less data in the departure data set and the employee IDs are not always matching it wouldn't make sense to join.

My desired result is the last table below. The blue part is a summary of the departure data. I can do the blue part of the table in PowerBI but I cannot add the yellow and red part (summary of total employees and leave rate by department and categories). When I try it just put 16 in all rows. Is there a way to do this in PowerBI? I looked into this: https://exceleratorbi.com.au/building-a-matrix-with-asymmetrical-columns-and-rows-in-power-bi/   but its not the same problem. The total and the departures are not in the same data set in my case.

Note: These are hypothetical examples, and my data sets have more rows.

Thanks.

 

 

total population: 

Rj0Ni.png

departure data set:

yX5FP.png

Desired result:

bstxa.png

  

 

 

data:

IDcategorieDepartment
1011BD1
1002BD1
1004CD2
1011CD2
1012AD2
1013AD1
1014CD2
1009BD2
1016BD2
1017CD2
1018AD3
1019CD2
1020BD2
1021BD3
1022BD3
1023AD1

 

IDcategorieDepartmentLeave reason
1001AD1Retirement
1002BD1Lay-off
1003CD3Retirement
1004CD2Resignation
1005AD2Resignation
1006AD1Retirement
1007CD2Lay-off
1008BD3Retirement
1009BD2Resignation
1010CD1Discharge
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, Matrix visual can partially achieved, but if you want to add two list in the matrix column, you should create a new table to custom the matrix. Here's my solution.

1.Create a new table. Don't make relationship with other tables

vkalyjmsft_0-1667443463795.png

2.Create a measure.

Measure =
VAR _GrandTotal =
    COUNT ( 'departure data'[ID] )
VAR _TotalPopulation =
    IF (
        ISINSCOPE ( 'departure data'[categorie] ),
        CALCULATE (
            COUNT ( 'total population'[ID] ),
            FILTER (
                'total population',
                'total population'[categorie] = MAX ( 'departure data'[categorie] )
            )
        ),
        COUNT ( 'total population'[ID] )
    )
RETURN
    IF (
        MAX ( 'Table'[Column] )
            IN { "Discharge", "Lay-off", "Resignation", "Retirement" },
        CALCULATE (
            COUNT ( 'departure data'[ID] ),
            FILTER (
                'departure data',
                'departure data'[Leave reason] = MAX ( 'Table'[Column] )
            )
        ),
        SWITCH (
            MAX ( 'Table'[Column] ),
            "Grand Total", _GrandTotal,
            "Total population", _TotalPopulation,
            "%leave rate", FORMAT ( DIVIDE ( _GrandTotal, _TotalPopulation ), "#%" )
        )
    )

Put Department and categorie column from departure data in the Matrix Rows, the new created Column in Matrix Columns, measure in Values, get the expected result:

vkalyjmsft_1-1667443676795.png

Notes:

1.To sort in the expected layout, I add an index column in the new table, and sort the new column by Index.

vkalyjmsft_2-1667443975283.png

2.I uncheck the Blank option of the new column in the visual filter.

vkalyjmsft_4-1667444132850.png

3.In your total population table, Department D3 only contains category A and B, but C is not included.

vkalyjmsft_5-1667444255819.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

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
Anonymous
Not applicable

This is awesome!! Thank you for your time!

v-yanjiang-msft
Community Support
Community Support

Hi @Anonymous ,

According to your description, Matrix visual can partially achieved, but if you want to add two list in the matrix column, you should create a new table to custom the matrix. Here's my solution.

1.Create a new table. Don't make relationship with other tables

vkalyjmsft_0-1667443463795.png

2.Create a measure.

Measure =
VAR _GrandTotal =
    COUNT ( 'departure data'[ID] )
VAR _TotalPopulation =
    IF (
        ISINSCOPE ( 'departure data'[categorie] ),
        CALCULATE (
            COUNT ( 'total population'[ID] ),
            FILTER (
                'total population',
                'total population'[categorie] = MAX ( 'departure data'[categorie] )
            )
        ),
        COUNT ( 'total population'[ID] )
    )
RETURN
    IF (
        MAX ( 'Table'[Column] )
            IN { "Discharge", "Lay-off", "Resignation", "Retirement" },
        CALCULATE (
            COUNT ( 'departure data'[ID] ),
            FILTER (
                'departure data',
                'departure data'[Leave reason] = MAX ( 'Table'[Column] )
            )
        ),
        SWITCH (
            MAX ( 'Table'[Column] ),
            "Grand Total", _GrandTotal,
            "Total population", _TotalPopulation,
            "%leave rate", FORMAT ( DIVIDE ( _GrandTotal, _TotalPopulation ), "#%" )
        )
    )

Put Department and categorie column from departure data in the Matrix Rows, the new created Column in Matrix Columns, measure in Values, get the expected result:

vkalyjmsft_1-1667443676795.png

Notes:

1.To sort in the expected layout, I add an index column in the new table, and sort the new column by Index.

vkalyjmsft_2-1667443975283.png

2.I uncheck the Blank option of the new column in the visual filter.

vkalyjmsft_4-1667444132850.png

3.In your total population table, Department D3 only contains category A and B, but C is not included.

vkalyjmsft_5-1667444255819.png

I attach my sample below for your reference.

 

Best Regards,
Community Support Team _ kalyj

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors