I have following table
Category
Category Id | Name | Parent Id | Category Level
-------------------------------------------------------------
1 | Vehicle | Null | 1
2 | Car | 1 | 2
3 | Sedan | 2 | 3
4 | Computer | Null | 1
5 | Laptop | 4 | 2
6 | Gaming | 5 | 3
7 | Alienware | 6 | 4
Level of category is decided based on Category hierarchy.
Here in Category table we have 2 main categories Vehicle and Computer
If I have selected the Level 4 then I want records on Category Level 4 if there is no level 4 in that category then I want the records on the lowest level. So in the output we'll get Sedan(Lowest in Vehicle) and Alienware(Level 4).
Can anyone suggest how can I achieve this in Power BI.
Considering Highest level: 4, let your table Category contains records as below
Now create a new table Category_new in Power Query Editor using this below code-
Here is your final output-