Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi
I'm setting up a new dataviz project for my company and I have a use case that I want to submit to this very active and great community 🙂
Context : all our data are stored in a postgre db. I connect to this db and load / transform data through a dataflow. Then my users will create reports based on a dataset that will be refreshed by the dataflow I mentionned above.
Problem I face : among the tables in the postgre db we have a table that contains the categories for our product. The table is self referencing with a structure like this :
category_id | category_name | category_parent_id | category_parent_name |
C001 | name001 | null | null |
C002 | name002 | C001 | name001 |
C003 | name003 | C001 | name001 |
C004 | name004 | C002 | name002 |
... | ... | ... | ... |
This creates a hierarchy of categories in which we publish our products. The hierarchy can be up to 4 levels. For instance :
Fruits & vegetable > Fruits > Apples > Golden
Fruits & vegetable > Fruits > Mango
We need this hierarchy in powerBI in order to group metrics per category (for instance, measuring the sales for one level of the category)
My first idea for a solution :
My first guess is to use the transformation capabilities of dataflows to recreate a table that contains the hierarchy :
Level 1 | Level 2 | Level 3 | Level 4 | category_id |
name001 | null | null | null | C001 |
name001 | name002 | null | null | C002 |
name001 | name003 | null | null | C003 |
name001 | name002 | name004 | null | C004 |
... |
|
If I can recreate this table, then I should be able to use it in powerBI reports, shouldn't I ?
My questions are the following :
Thanks for your help !
Gérald
Solved! Go to Solution.
The DAX functions are created specifically for this purpose, for me I would stick with that.
You could replicate this in your dataflow, or even in your warehouse by creating a flattened hierarchy. If your hierarchy will have the same amount of levels it would make sense to do it at warehouse and store as a table for the sake of using in multiple report solutions.
Hi,
Please read through this.
https://learn.microsoft.com/en-us/dax/understanding-functions-for-parent-child-hierarchies-in-dax
In addition you may want to take a look at 'Hierarchy Slicer' visual from the market place which offers more features than the standard microsoft visual
Hi @ajohnso2
Thanks for your reply. I read the document you shared with me. I think DAX could be a good solution but I'm wondering if I'd rather do the transformation in the dataflow itself.
So i tried the following solution :
What do you think of this solution ? Should I keep it or aim for a transformation in the dataset with DAX ?
I find it hard to decide what's the best implementation.
BR
Gérald
The DAX functions are created specifically for this purpose, for me I would stick with that.
You could replicate this in your dataflow, or even in your warehouse by creating a flattened hierarchy. If your hierarchy will have the same amount of levels it would make sense to do it at warehouse and store as a table for the sake of using in multiple report solutions.
Hi @ajohnso2
I think that I'd rather put it in the dataflow when transforming data rather than in the dataset or any report with DAX. Indeed, I feel that I should prepare data as early as possible in the data loading process and then make it available to all users with a shared syntax. This would allow us to ensure consistency through all reports.
Thanks for sharing the link !
User | Count |
---|---|
46 | |
26 | |
21 | |
19 | |
18 |
User | Count |
---|---|
51 | |
46 | |
24 | |
21 | |
20 |