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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Brandonkersgoed
Frequent Visitor

Power BI/Dax Matrix

Hey Power BI Community,

I'm struggling trying to put a matrix together, right now I have a table, I want to make a matrix showing a count with how many items are shown with eachother in each ID. Table 1 exists in my data currently, however I'm not sure whether I need to make a new table in Power BI, or make a matrix using a chart. 

I tried making a chart with the product as both row and column, but not sure how to get the count right (I got the total count of rows instead of the unique products in the matrix).

Table 1 (data):

IDProduct
1Apple,Apple, Apple
2Apple,Chocolate
3Apple,Chocolate, Apple
4Orange, Chocolate
5Chocolate, Chocolate, Orange

Desired output:

 AppleOrangeChocolate
Apple304
Orange202
Chocolate424

 

Any help here would be greatly appreciated!

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Brandonkersgoed 
Please refer to attached file with the solution

2.png1.png

Measure = 
VAR Product1 = SELECTEDVALUE ( Filter1[Product] )
VAR Product2 = SELECTEDVALUE ( Filter2[Product] )
RETURN
    COUNTROWS (
        FILTER (
            'Table',
            CONTAINSSTRING ( 'Table'[Product], Product1 )
                && CONTAINSSTRING ( 'Table'[Product], Product2 )
        )
    ) + 0

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi  @Brandonkersgoed ,

Here are the steps you can follow:

1. In Power Query - select [Product]. - Split Column - By Delimiter.

vyangliumsft_0-1662535187266.png

Result:

vyangliumsft_1-1662535187269.png

2. Select the column marked in yellow – Unpivot Columns.

vyangliumsft_2-1662535187273.png

3. Select the [Value] column in the new table - Transform - Trim.

vyangliumsft_3-1662535187276.png

4. Create a table with Enter data.

vyangliumsft_4-1662535187278.png

5. Create measure.

 

Measure 2 =
var _orange=
CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Value]=MAX('Table'[Value])&&'Table'[Value]=MAX('Table2'[Product])))
var _apple=
CALCULATE(DISTINCTCOUNT('Table'[ID]),FILTER(ALL('Table'),'Table'[Value]=MAX('Table'[Value])))
return
IF(MAX('Table2'[Product])="Orange",_orange,IF(MAX('Table2'[Product])="Apple"&&MAX('Table'[Value])="Apple",_apple+1,_apple))

 

6. Result:

vyangliumsft_5-1662535187285.png

 

If you need pbix, please click here.

Power BI Dax Matrix.pbix

 

Best Regards,

Liu Yang

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

tamerj1
Super User
Super User

Hi @Brandonkersgoed 
Please refer to attached file with the solution

2.png1.png

Measure = 
VAR Product1 = SELECTEDVALUE ( Filter1[Product] )
VAR Product2 = SELECTEDVALUE ( Filter2[Product] )
RETURN
    COUNTROWS (
        FILTER (
            'Table',
            CONTAINSSTRING ( 'Table'[Product], Product1 )
                && CONTAINSSTRING ( 'Table'[Product], Product2 )
        )
    ) + 0

Thanks @tamerj1!

Worked exactly how I needed it to for my set.

Truly appreciate the help

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.