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 August 31st. Request your voucher.

Reply
LoryMenCR
Helper I
Helper I

Measure as a row in matrix

Dear All,

i have the following matrix visual

GroupValue
Group Description A5000
Group Description B- 2000
Group Description C- 5000
Group Description D+3000
Total1000

 

I have created a measure which basically do a calculation on groups.

For example:

Measure1= Group Description A - Group Description B.

 

Now I need to insert this measure as a row in the matrix, as follows:

GroupValue
Group Description A5000
Group Description B- 2000
Measure13000
Group Description C- 5000
Group Description D+3000
Total1000

 

I am not able to do this.

 

If I insert my measure in the field value of the matrix, this is what I get:

GroupValueMeasure1
Group Description A50005000
Group Description B- 2000-2000
Group Description C- 50000
Group Description D+30000
Total10003000

 

Do you have a solution for this case?
Thank you a lot

2 ACCEPTED SOLUTIONS
Kedar_Pande
Super User
Super User

@LoryMenCR 

Create a Supporting Table for Groups:

GroupTable = 
DATATABLE(
"Group", STRING,
{
{"Group Description A"},
{"Group Description B"},
{"Measure1"},
{"Group Description C"},
{"Group Description D"}
}
)

Create the Measure for Measure1:

Measure1 = 
VAR GroupA_Value = CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description A")
VAR GroupB_Value = CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description B")
RETURN GroupA_Value - GroupB_Value

Add a Dynamic Measure for the Value Column:

DynamicValue = 
SWITCH(
TRUE(),
SELECTEDVALUE('GroupTable'[Group]) = "Group Description A", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description A"),
SELECTEDVALUE('GroupTable'[Group]) = "Group Description B", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description B"),
SELECTEDVALUE('GroupTable'[Group]) = "Measure1", [Measure1],
SELECTEDVALUE('GroupTable'[Group]) = "Group Description C", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description C"),
SELECTEDVALUE('GroupTable'[Group]) = "Group Description D", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description D"),
BLANK()
)

Add GroupTable[Group] to the Rows field in the matrix visual.
Add the DynamicValue measure to the Values field in the matrix.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

View solution in original post

Anonymous
Not applicable

Hi @LoryMenCR , hello Kedar_Pande, thank you for your prompt reply!

I agree with Kedar_Pande.

 

Additionally, you might consider adding a sort order column to the supporting table.

 

This will help control the display order of the rows in the matrix.

GroupsTable = DATATABLE(
    "Group", STRING,
    "SortOrder", INTEGER,
    {
        {"Group Description A", 1},
        {"Group Description B", 2},
        {"Measure1", 3},
        {"Group Description C", 4},
        {"Group Description D", 5}
    }
)

Next, sort the group column using the sort order as illustrated below:

vyajiewanmsft_0-1732258006864.png

Then, utilize the measure mentioned by Kedar Pande for your reference:

vyajiewanmsft_1-1732258067125.png

Based on my test, since the group description for value b is -2000, we need to apply the ABS function to ensure it uses the correct value.

Measure1 = 
VAR GroupA_Value = CALCULATE(SUM('Table'[Value]), 'Table'[Group] = "Group Description A")
VAR GroupB_Value = CALCULATE(SUM('Table'[Value]), 'Table'[Group] = "Group Description B")
RETURN GroupA_Value - ABS(GroupB_Value)

 

Best regards,

Joyce

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

Hi @LoryMenCR , hello Kedar_Pande, thank you for your prompt reply!

I agree with Kedar_Pande.

 

Additionally, you might consider adding a sort order column to the supporting table.

 

This will help control the display order of the rows in the matrix.

GroupsTable = DATATABLE(
    "Group", STRING,
    "SortOrder", INTEGER,
    {
        {"Group Description A", 1},
        {"Group Description B", 2},
        {"Measure1", 3},
        {"Group Description C", 4},
        {"Group Description D", 5}
    }
)

Next, sort the group column using the sort order as illustrated below:

vyajiewanmsft_0-1732258006864.png

Then, utilize the measure mentioned by Kedar Pande for your reference:

vyajiewanmsft_1-1732258067125.png

Based on my test, since the group description for value b is -2000, we need to apply the ABS function to ensure it uses the correct value.

Measure1 = 
VAR GroupA_Value = CALCULATE(SUM('Table'[Value]), 'Table'[Group] = "Group Description A")
VAR GroupB_Value = CALCULATE(SUM('Table'[Value]), 'Table'[Group] = "Group Description B")
RETURN GroupA_Value - ABS(GroupB_Value)

 

Best regards,

Joyce

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

Kedar_Pande
Super User
Super User

@LoryMenCR 

Create a Supporting Table for Groups:

GroupTable = 
DATATABLE(
"Group", STRING,
{
{"Group Description A"},
{"Group Description B"},
{"Measure1"},
{"Group Description C"},
{"Group Description D"}
}
)

Create the Measure for Measure1:

Measure1 = 
VAR GroupA_Value = CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description A")
VAR GroupB_Value = CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description B")
RETURN GroupA_Value - GroupB_Value

Add a Dynamic Measure for the Value Column:

DynamicValue = 
SWITCH(
TRUE(),
SELECTEDVALUE('GroupTable'[Group]) = "Group Description A", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description A"),
SELECTEDVALUE('GroupTable'[Group]) = "Group Description B", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description B"),
SELECTEDVALUE('GroupTable'[Group]) = "Measure1", [Measure1],
SELECTEDVALUE('GroupTable'[Group]) = "Group Description C", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description C"),
SELECTEDVALUE('GroupTable'[Group]) = "Group Description D", CALCULATE(SUM('MainTable'[Value]), 'MainTable'[Group] = "Group Description D"),
BLANK()
)

Add GroupTable[Group] to the Rows field in the matrix visual.
Add the DynamicValue measure to the Values field in the matrix.

 

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.