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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
darwindat
Helper I
Helper I

Values in Matrix shown based on different row context

Hello everyone, 

I have one issue and would really appreciate any help or idea. 

I create a Matrix, based on a (simplified) dataset (can be seen in the picture below). I have 2 columns A, and B and a Value column. 

Is it possible if with only 1 column in the same Matrix - (called Column in the picture), we can create 2 measures, one showing the sum of value based on the Row context of Column A (I called this measure: Column A row context), and another showing the sum of values based on the Row context of Column B (Column B row context). The "Desired Matrix" is what I want to achieve (I did it by Excel). 
I hope it would be easier to understand my question with the below picture and my example pbix file.

Thanks in advance! 

 

example.png

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

Create a dimension table

Dim = distinct(table[A])
Or
Dim = distinct(union(all(table[A]),all(table[B])))

 

Join it both columns A and B, One join will be active. Another one will be inactive. use userelation to activate the join in the formula for column B

How to use userelation refer :https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Check for terminations

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

MFelix
Super User
Super User

Hi @darwindat ,

 

Create a dimension table with distinct values from the Column A and Column B then make two inactive relationships between this new table and the two columns A and B then add the following two measures:

Contex A = CALCULATE(SUM('Table'[Value]); USERELATIONSHIP('Table'[Column A];'Row Context'[Column Context]))

Contex B = CALCULATE(SUM('Table'[Value]); USERELATIONSHIP('Table'[Column B];'Row Context'[Column Context]))

 

Add the column from the new table as your main context on your table and filter out all the blanks.

 

check PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

3 REPLIES 3
MFelix
Super User
Super User

Hi @darwindat ,

 

Create a dimension table with distinct values from the Column A and Column B then make two inactive relationships between this new table and the two columns A and B then add the following two measures:

Contex A = CALCULATE(SUM('Table'[Value]); USERELATIONSHIP('Table'[Column A];'Row Context'[Column Context]))

Contex B = CALCULATE(SUM('Table'[Value]); USERELATIONSHIP('Table'[Column B];'Row Context'[Column Context]))

 

Add the column from the new table as your main context on your table and filter out all the blanks.

 

check PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Thank you guys @MFelix and @amitchandak for your great help! 🙂 They are same solutions and they work! Thanks!

 

amitchandak
Super User
Super User

Create a dimension table

Dim = distinct(table[A])
Or
Dim = distinct(union(all(table[A]),all(table[B])))

 

Join it both columns A and B, One join will be active. Another one will be inactive. use userelation to activate the join in the formula for column B

How to use userelation refer :https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-tr...

Check for terminations

 

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
In case it does not help, please provide additional information and mark me with @

Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
Connect on Linkedin

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
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.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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