Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowGet inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.
Hi,
I have a customer requirement to show the parent bar along with it's child bars in a bar chart.
For example, If we have the following hierachy: Global --> Region --> Country --> State --> District.
The top level bar graph will contain one bar for Global and one bar for each Region.
Second level will contain one bar for the Region which is drilled down and one bar for each Country.
Third level will contain one bar for the Country which is drilled down and one bar for each State.
Hope the question is clear.
I would really appreciate some help here.
Thanks.
Solved! Go to Solution.
Hi @AshishJuneja ,
Try this:
Reogin Country =
UNION (
ADDCOLUMNS (
VALUES ( 'Table'[Region] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Region] ),
FILTER ( 'Table', 'Table'[Region] <= EARLIER ( 'Table'[Region] ) )
)
),
ADDCOLUMNS (
VALUES ( 'Table'[Country] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Country] ),
FILTER ( 'Table', 'Table'[Country] <= EARLIER ( 'Table'[Country] ) )
)
+ DISTINCTCOUNT ( 'Table'[Region] )
)
)
Country State =
UNION (
ADDCOLUMNS (
VALUES ( 'Table'[Country] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Country] ),
FILTER ( 'Table', 'Table'[Country] <= EARLIER ( 'Table'[Country] ) )
)
),
ADDCOLUMNS (
VALUES ( 'Table'[State] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[State] ),
FILTER ( 'Table', 'Table'[State] <= EARLIER ( 'Table'[State] ) )
)
+ DISTINCTCOUNT ( 'Table'[Country] )
)
)
State District =
UNION (
ADDCOLUMNS (
VALUES ( 'Table'[State] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[State] ),
FILTER ( 'Table', 'Table'[State] <= EARLIER ( 'Table'[State] ) )
)
),
ADDCOLUMNS (
VALUES ( 'Table'[District] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[District] ),
FILTER ( 'Table', 'Table'[District] <= EARLIER ( 'Table'[District] ) )
)
+ DISTINCTCOUNT ( 'Table'[State] )
)
)
Modified Measure =
SWITCH (
TRUE (),
ISFILTERED ( 'State District'[State] ),
IF (
MAX ( 'State District'[State] ) IN VALUES ( 'Table'[District] ),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[District] = MAX ( 'State District'[State] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
&& 'Table'[State] = MAX ( 'Country State'[Country] )
)
),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[State] = MAX ( 'State District'[State] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
&& 'Table'[State] = MAX ( 'Country State'[Country] )
)
)
),
ISFILTERED ( 'Country State'[Country] ),
IF (
MAX ( 'Country State'[Country] ) IN VALUES ( 'Table'[State] ),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[State] = MAX ( 'Country State'[Country] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
)
),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[Country] = MAX ( 'Country State'[Country] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
)
)
),
ISFILTERED ( 'Reogin Country'[Region] ),
IF (
MAX ( 'Reogin Country'[Region] ) IN VALUES ( 'Table'[Country] ),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER ( 'Table', 'Table'[Country] = MAX ( 'Reogin Country'[Region] ) )
),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER ( 'Table', 'Table'[Region] = MAX ( 'Reogin Country'[Region] ) )
)
),
SUM ( 'Table'[Measure] )
)
For more details, please check the attached .pbix file.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @AshishJuneja ,
Try this:
Reogin Country =
UNION (
ADDCOLUMNS (
VALUES ( 'Table'[Region] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Region] ),
FILTER ( 'Table', 'Table'[Region] <= EARLIER ( 'Table'[Region] ) )
)
),
ADDCOLUMNS (
VALUES ( 'Table'[Country] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Country] ),
FILTER ( 'Table', 'Table'[Country] <= EARLIER ( 'Table'[Country] ) )
)
+ DISTINCTCOUNT ( 'Table'[Region] )
)
)
Country State =
UNION (
ADDCOLUMNS (
VALUES ( 'Table'[Country] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[Country] ),
FILTER ( 'Table', 'Table'[Country] <= EARLIER ( 'Table'[Country] ) )
)
),
ADDCOLUMNS (
VALUES ( 'Table'[State] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[State] ),
FILTER ( 'Table', 'Table'[State] <= EARLIER ( 'Table'[State] ) )
)
+ DISTINCTCOUNT ( 'Table'[Country] )
)
)
State District =
UNION (
ADDCOLUMNS (
VALUES ( 'Table'[State] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[State] ),
FILTER ( 'Table', 'Table'[State] <= EARLIER ( 'Table'[State] ) )
)
),
ADDCOLUMNS (
VALUES ( 'Table'[District] ),
"Order",
CALCULATE (
DISTINCTCOUNT ( 'Table'[District] ),
FILTER ( 'Table', 'Table'[District] <= EARLIER ( 'Table'[District] ) )
)
+ DISTINCTCOUNT ( 'Table'[State] )
)
)
Modified Measure =
SWITCH (
TRUE (),
ISFILTERED ( 'State District'[State] ),
IF (
MAX ( 'State District'[State] ) IN VALUES ( 'Table'[District] ),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[District] = MAX ( 'State District'[State] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
&& 'Table'[State] = MAX ( 'Country State'[Country] )
)
),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[State] = MAX ( 'State District'[State] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
&& 'Table'[State] = MAX ( 'Country State'[Country] )
)
)
),
ISFILTERED ( 'Country State'[Country] ),
IF (
MAX ( 'Country State'[Country] ) IN VALUES ( 'Table'[State] ),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[State] = MAX ( 'Country State'[Country] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
)
),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER (
'Table',
'Table'[Country] = MAX ( 'Country State'[Country] )
&& 'Table'[Country] = MAX ( 'Reogin Country'[Region] )
)
)
),
ISFILTERED ( 'Reogin Country'[Region] ),
IF (
MAX ( 'Reogin Country'[Region] ) IN VALUES ( 'Table'[Country] ),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER ( 'Table', 'Table'[Country] = MAX ( 'Reogin Country'[Region] ) )
),
CALCULATE (
SUM ( 'Table'[Measure] ),
FILTER ( 'Table', 'Table'[Region] = MAX ( 'Reogin Country'[Region] ) )
)
),
SUM ( 'Table'[Measure] )
)
For more details, please check the attached .pbix file.
Best Regards,
Icey
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks @TheoC for the quick response. You can assume the data to be like as given below. I have tried reformatting the data to achieve the same but it didn't work out. To provide further details, I tried create a row for total for each parent at the child row, so that i can get it at the same axis, but with multiple hierarchy and drill down required, it is not working as expected. If you have any other ideas that will be very helpful.
Region | Country | State | District | Measure |
R | P | W | A | 100 |
R | P | W | B | 200 |
R | P | X | C | 300 |
R | P | X | D | 400 |
R | Q | Y | E | 500 |
R | Q | Y | F | 600 |
R | Q | Z | G | 700 |
R | Q | Z | H | 800 |
Requirement: Initially, Show a bar for Region and two bar for Countries(P and Q).
When drilled down on P, the chart will show one bar for P and two bars for it;s two children(W and X) and so on.
Thanks.
Beautiful! You can just layer the columns under the X Axis like the below screenshot. From here, you can then just use the drilldown buttons on the visual to get to next layer 🙂
I have also attached PBIX to further assist.
Hope this helps 🙂
Theo
If I have posted a response that resolves your question, please accept it as a solution to formally close the post.
Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!
Want to connect?www.linkedin.com/in/theoconias
Hi @TheoC,
With the given solution I can see all the sub categories but that is not what I intend to achieve. What I need is:
Initially, Show a bar for Region and two bar for Countries(P and Q).
When drilled down on P, the chart will show one bar for P and two bars for it's two children(W and X) and so on.
Thanks.
Set it up like the below image and then use the Single Drill Down button (updated PBIX attached).
Hope this helps 🙂
If I have posted a response that resolves your question, please accept it as a solution to formally close the post.
Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!
Want to connect?www.linkedin.com/in/theoconias
Depending on how the your data is structured, you should be able to layer the hierarchy in order on the X-Axis field in the Visualisation pane and then use the drilldown feature on the chart itself to go down to the next level(s).
If the above doesn't assist, can you provide an example of your data.
Thank you 🙂
Theo
If I have posted a response that resolves your question, please accept it as a solution to formally close the post.
Also, if you are as passionate about Power BI, DAX and data as I am, please feel free to reach out if you have any questions, queries, or if you simply want to connect and talk to another data geek!
Want to connect?www.linkedin.com/in/theoconias
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
86 | |
69 | |
66 | |
51 | |
32 |
User | Count |
---|---|
114 | |
99 | |
75 | |
65 | |
40 |