Forum Discussion
Cluster Bar Chart and Hierarchy
- 4 years ago
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" ) )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]
Check PBIX file attach.
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?
Thanks, Miguel.
Yes, I would ike the dynamic change in the bar chart according to the level of hierarchy.
- MFelix4 years ago
Super User
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" ) )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]
Check PBIX file attach.