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
chrisx
Frequent Visitor

Cluster Bar Chart and Hierarchy

Hello all,

 

I have built a clustered bar chart that looks great. The different columns are regions in a data set I am working with. I am having an issue with the slicer I am using.

chrisx_5-1636558260793.png

 

 

I am using a hierarchy in the slicer. I'd like to drill down into the different levels of the hierarchy . But when I do so, I do not get the clusters of the next level of the hierarchy.

 

chrisx_2-1636557682618.png

 

When I enter the hierarchy into the 'Legend' section, only the top level of the hierarchy is entered. And it goves me one bar as pictured below, instead of the cluster I am looking for.

chrisx_6-1636559140990.png

 

Any ideas on how I could correct this?

 

Thank you!

 

 

 

 

1 ACCEPTED SOLUTION

Hi @chrisx ,

 

You need to make a unrelated table and a measure to make this work.

 

Create the following table:

Regions =
UNION (
    ADDCOLUMNS ( DISTINCT ( 'Table'[Region] ), "Category", "Region" ),
    ADDCOLUMNS ( DISTINCT ( 'Table'[SubRegion] ), "Category", "SubRegion" ),
    ADDCOLUMNS ( DISTINCT ( 'Table'[Office] ), "Category", "Office" )
)

 

MFelix_0-1637055142357.png

 

Add the following measure to your model:

Hierarchy Values =
SWITCH (
    TRUE (),
    HASONEVALUE ( 'Table'[SubRegion] ),
        CALCULATE (
            SUM ( 'Table'[Values] ),
            'Table'[Office] = MAX ( 'Regions'[Region] )
        ),
    HASONEVALUE ( 'Table'[Region] ),
        CALCULATE (
            SUM ( 'Table'[Values] ),
            'Table'[SubRegion] = MAX ( 'Regions'[Region] )
        ),
    CALCULATE (
        SUM ( 'Table'[Values] ),
        'Table'[Region] = MAX ( 'Regions'[Region] )
    )
)

 

Now setup your chart in the following way:

  • Axis: Regions[Region]
  • Legend: Table[Cat]
  • Values: [Hierarchy Values]

MFelix_1-1637055252259.pngMFelix_2-1637055266985.png

 

Check PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
Susanta91
Frequent Visitor

Great work! @MFelix . Using the same technique and bit changes in measure we can use dynamic legend as well like Parker have shared the technique in his YouTube channel @Bielite and blog post. However, your perception is also applicable. Keep doing some extraordinary job like this.

Hi @Susanta91 ,

 

Currently with the Field parameters, this is even easier to do without the need of disconnected tables. but appreciate your words.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



v-yangliu-msft
Community Support
Community Support

Hi  @chrisx ,

You need to click the following icon to drill down and then select the slicer.

vyangliumsft_0-1637045661469.png

Then you can get the visual object of the hierarchical structure:

vyangliumsft_1-1637045661473.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

MFelix
Super User
Super User

Hi @chrisx ,

 

If your cluster in the bar chart is the region then when you use the slicer you get only a single column because the slicer and the bar chart have the same level of granularity, if you want to show the details of the Subregion then you need to do that on the bar chart.

 

One question do you want to have a dinamic change of the bar chart according to the level of the hierarchy slicer you select, so when selecting region you get the bar chart divided by Subregion?


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



chrisx
Frequent Visitor

Thanks, Miguel.

 

Yes, I would ike the dynamic change in the bar chart according to the level of hierarchy.

Hi @chrisx ,

 

You need to make a unrelated table and a measure to make this work.

 

Create the following table:

Regions =
UNION (
    ADDCOLUMNS ( DISTINCT ( 'Table'[Region] ), "Category", "Region" ),
    ADDCOLUMNS ( DISTINCT ( 'Table'[SubRegion] ), "Category", "SubRegion" ),
    ADDCOLUMNS ( DISTINCT ( 'Table'[Office] ), "Category", "Office" )
)

 

MFelix_0-1637055142357.png

 

Add the following measure to your model:

Hierarchy Values =
SWITCH (
    TRUE (),
    HASONEVALUE ( 'Table'[SubRegion] ),
        CALCULATE (
            SUM ( 'Table'[Values] ),
            'Table'[Office] = MAX ( 'Regions'[Region] )
        ),
    HASONEVALUE ( 'Table'[Region] ),
        CALCULATE (
            SUM ( 'Table'[Values] ),
            'Table'[SubRegion] = MAX ( 'Regions'[Region] )
        ),
    CALCULATE (
        SUM ( 'Table'[Values] ),
        'Table'[Region] = MAX ( 'Regions'[Region] )
    )
)

 

Now setup your chart in the following way:

  • Axis: Regions[Region]
  • Legend: Table[Cat]
  • Values: [Hierarchy Values]

MFelix_1-1637055252259.pngMFelix_2-1637055266985.png

 

Check PBIX file attach.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



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.

Top Solution Authors