Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
I have the following table
RECORD_ID | TAG |
1 | TAG1 |
1 | TAG2 |
2 | TAG1 |
2 | TAG3 |
I would like to get a heatmap of co-occurrencies. In matrix form, it would be
TAG1 | TAG2 | TAG3 | |
TAG1 | count of record_id with tag1 | count of record_id with tag1 and tag2 | count of record_id with tag1 and tag3 |
TAG2 | count of record_id with tag2 and tag1 | count of record_id with tag2 | count of record_id with tag2 and tag3 |
TAG3 | count of record_id with tag3 and tag1 | count of record_id with tag3 and tag2 | count of record_id with tag3 |
which, in this case, is a symmetric matrix. Then I would like to color the cell based on the value.
I guess to obtain that matrix I should pivot my table on TAG and use those counts as values, but I am not familiar with PowerBi and DAX, so how can I achieve this? and how can I get the coloured heatmap? Is there a more direct way to achieve my goal?
Solved! Go to Solution.
@Anonymous - See PBIX attached below sig. Tables (31) and (31a). First, create disconnected table from original like this:
Table (31a) = DISTINCT('Table (31)'[TAG])
Then this measure:
Measure 31 =
VAR __Table1 = SELECTCOLUMNS('Table (31)',"Record",[RECORD_ID])
VAR __Table2 = SELECTCOLUMNS(FILTER(ALL('Table (31)'),[TAG]=MAX('Table (31a)'[TAG])),"Record",[RECORD_ID])
RETURN
COUNTROWS(INTERSECT(__Table1,__Table2))
Put [TAG] from (31) in Rows of a Matrix, [TAG] from (31a) in Columns, Measure 31 in Values.
@Anonymous - See PBIX attached below sig. Tables (31) and (31a). First, create disconnected table from original like this:
Table (31a) = DISTINCT('Table (31)'[TAG])
Then this measure:
Measure 31 =
VAR __Table1 = SELECTCOLUMNS('Table (31)',"Record",[RECORD_ID])
VAR __Table2 = SELECTCOLUMNS(FILTER(ALL('Table (31)'),[TAG]=MAX('Table (31a)'[TAG])),"Record",[RECORD_ID])
RETURN
COUNTROWS(INTERSECT(__Table1,__Table2))
Put [TAG] from (31) in Rows of a Matrix, [TAG] from (31a) in Columns, Measure 31 in Values.
Thanks @Greg_Deckler! may I ask you to elaborate a bit more on what the variable __table2 is? I am not quite sure what happens there, and I'd like to understand the process. Thank you.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
106 | |
68 | |
48 | |
47 | |
47 |