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.
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?
Solved! Go to Solution.
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
After above steps, you can use these columns to create custom hierarchy.
Regards,
Xiaoxin Sheng
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
After above steps, you can use these columns to create custom hierarchy.
Regards,
Xiaoxin Sheng
@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.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
98 | |
78 | |
64 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |