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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Create matrix visual based on values in two table columns

Hi lovely people,

 

I have a table loaded in Power BI with many columns, of which two are columns with abbreviations of country name. Let's call these columns 'Country A' and 'Country B', and the table containing these columns 'Countries'. For most rows, the country in the 'Country A' column is the same as the country in the 'Country B' column, but for some rows they are different. You can assume that the countries in both columns are consistently named, i.e. France is abbreviated FR and Italy is abbreviated IT is both columns.

 

I would now like to create a matrix where the columns represent the countries in the Country A column and the rows represent the countries in the Country B column, and each value in the matrix is supposed to be the number of rows with that combination of countries.

 

For example, for the Countries table:

Row No.Country ACountry B
1USIT
2FRFR
3ITFR
4FRUS
5FRUS

I would like to get the matrix:

 

Country AFRITUS
Country B   
FR110
IT001
US200

 

because on 1 row country A is equal to US and country B is IT, and on 2 rows country A is equal to FR and country B is equal two US and so on.

 

The table (loaded from an Excel sheet) is in fact much larger, but I hope that you understand my issue here. I suppose this problem can be solved using DAX in some way, but I am unsure how.

 

I would be very thankful if anyone could help me out with this. Many thanks in advance!

 

Kind regards,

Bertan

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

First create a dimension table as below:

Table 2 = DISTINCT(UNION(VALUES('Table'[Country A]),VALUES('Table'[Country B])))

Then create a measure as below:

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Country A]=MAX('Table 2'[Country A])))+0

And you will see:

Screenshot 2020-10-23 152600.png

For the related .pbix ,pls see attached.

 

Best Regards,
Kelly

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

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

First create a dimension table as below:

Table 2 = DISTINCT(UNION(VALUES('Table'[Country A]),VALUES('Table'[Country B])))

Then create a measure as below:

Measure = CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[Country A]=MAX('Table 2'[Country A])))+0

And you will see:

Screenshot 2020-10-23 152600.png

For the related .pbix ,pls see attached.

 

Best Regards,
Kelly

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

Anonymous
Not applicable

The matrix visual is similar to a table. A table supports two dimensions and the data is flat, meaning duplicate values are displayed and not aggregated. A matrix makes it easier to display data meaningfully across multiple dimensions -- it supports a stepped layout. The matrix automatically aggregates the data and enables drill down.

You can create matrix visuals in Power BI Desktop reports and cross-highlight elements within the matrix with other visuals on that report page. For example, you can select rows, columns, and even individual cells and cross-highlight. Also, individual cells and multiple cell selections can be copied and pasted into other applications.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.