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
webportal
Impactful Individual
Impactful Individual

Create hierarchy in matrix visual for financial reporting

Hello,

 

I'm trying to create a hierarchy for a profit and loss statement where accounts have 2 to 9 digits.

 

For example:

 

Account nr.    Value

11                      100

111                      20

112                      30

113                      50

 

So, in Excel I have a column with the account number and 8 other columns to the left with Level2 to Level9 account numbers.

 

But the problem then is how to create a hierarchy in PBI Desktop that works.

 

For example, in the table above Level4 is empty, because there are no level 4 accounts. So, creating a hierarchy field and a matrix visual will get me a lot of empty values!

 

I want to be able to drill down from level 2 to level 9 and always see the correct values.

 

I've read a lot of stuff in other Posts around the web, including DAX books, etc. But How can I make such a simple visual work?

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

Hi @webportal,

 

For you scenario, you can write a recursive calculation to find out the previous parent, then create column parent to store these result.

 

Sample:

let
    SearchParent=(list as list, item as number)=> 
    let
        temp= if item > 10 then List.Select(list, each _= Int32.From(item/10)) else {item},
        result= if List.Count(temp)>0 then List.First(temp) else Search(list, Int32.From(item/10))
    in
        result
in
    SearchParent

 

 5.PNG6.PNG

 

After above steps, you can use these columns to create custom hierarchy.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @webportal,

 

For you scenario, you can write a recursive calculation to find out the previous parent, then create column parent to store these result.

 

Sample:

let
    SearchParent=(list as list, item as number)=> 
    let
        temp= if item > 10 then List.Select(list, each _= Int32.From(item/10)) else {item},
        result= if List.Count(temp)>0 then List.First(temp) else Search(list, Int32.From(item/10))
    in
        result
in
    SearchParent

 

 5.PNG6.PNG

 

After above steps, you can use these columns to create custom hierarchy.

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

@v-shex-msft thank you.

 

Since my knowledge of M is quite limited, I managed to determine the parent in Excel.

Then using PATH and PATHITEM, I've created the hierarchy.

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.