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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
salemhaddad
Frequent Visitor

Matrix with multiple hierarchy

Hello,

 

I have a table that contains father_code and for each one of them there is a son code(it's like category and subcategory).

In parallel with, i have a corresponding label that corresponds to heach category. (It's like having Cateogry and subcategory and with it color and subcolor).

 

Note: The son code here is the first element as there is no father code for it.

 

Here is my table: 

Son_codeFather_codeLabel
A 1
BA3
HA2
EA4
FA5
CB6
DB7

 

I tried using matrix to visualize the data but it does not work with double hiearchies as the first son code is not the real son code but the father code.

 

Here is a formatted table to understand the problem and how the output should show: 

 CODELABEL
+A1
-A|H1|2
-A|B1|3
-A|F1|5
-A|E1|4
-A|B|C1 | 3 | 6
-A|B|D1|3 | 7

 

If you have any idea on that either matrix or using DAX to format that.

 

Thank you in advance,

Salem

2 ACCEPTED SOLUTIONS
Wilson_
Memorable Member
Memorable Member

Hey salemhaddad,

 

Look into the PATH DAX function. Here's a link to some documentation. It seems to be exactly what you need.


----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

 

P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.

View solution in original post

salemhaddad
Frequent Visitor

4 REPLIES 4
salemhaddad
Frequent Visitor

It works by putting it as column and not a measure.

https://community.fabric.microsoft.com/t5/Desktop/PATH-DAX-Measure-A-table-of-multiple-values-was-su...

Thank you very much.

You're welcome!

salemhaddad
Frequent Visitor

Thank you very much for the recommandation.

 

I tried to use it: 

DEFINE
  VAR path_column = PATH(table[Son_code], table[Father_code])
 
  EVALUATE
    SELECTCOLUMNS(table,table[Son_code], table[Father_code], 
"path_column", path_column
)
 
It give an error: A table of multiple values was supplied where a single value was expected.
Wilson_
Memorable Member
Memorable Member

Hey salemhaddad,

 

Look into the PATH DAX function. Here's a link to some documentation. It seems to be exactly what you need.


----------------------------------
If this post helps, please consider accepting it as the solution to help other members find it quickly. Also, don't forget to hit that thumbs up and subscribe! (Oh, uh, wrong platform?)

 

P.S. Need a more in-depth consultation for your Power BI data modeling or DAX issues? Feel free to hire me on Upwork or DM me directly on here! I would love to clear up your Power BI headaches.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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