· 

Power BI's new Stacked bar chart

Personally, the stacked bar chart holds a special place in my heart when it comes to data visualization. It's the tool I find myself using most frequently, which is why I decided to share a template using Deneb that I’ve been utilizing for a considerable amount of time: https://www.minceddata.info/2023/11/12/the-better-rectangular-pie-chart/

 

With the December 2023 release of Power BI Desktop, I can almost create the Deneb visual, which is fantastic as it eliminates the need for an additional custom visual. It's important to note that while I’m a huge fan of Deneb, I also serve as the Power BI/Fabric sherpa in a large organization, and for this, I always try to reduce overall system complexity.

 

This article is about how I created the below data visualization:

One of the greatest features of the Power BI December 2023 release is the ability to order the segments (the Color name) inside a stack (the Continent name).

Most of the time, when creating a stacked bar or column chart, my focus is the total value of the stacks, not the comparison of the segments across stacks. Ordering the segments by value still allows us to easily spot differences in the importance of segments across the stacks. The ordering of segments by value can be achieved by using the properties “Reverse order” and “Sort by value” in the new Layout card in the Bars section as depicted in the following image:

Next to ordering the segments, there are also enhancements to the data labeling. It’s now possible to have three more or less fully customizable labels per segment. These three labels are shown in the next image:

By default Title shows the Series name (the Color) but can be customized, Value of course shows the Value (here it’s the SalesAmount), Detail allows adding more information. In this example, I combined the percentage contribution of a segment to the stack with the additive contribution of the segments. Unfortunately, the visual does not automate these two common calculations; instead, I have to provide the measures. Nevertheless, because I’ve done these calculations quite often, it is not a big deal.

Here are the measures:

The measure that combines the individual calculations (of course, everything can be done in a single measure):


vizAid Salesamount Custom Detaillabel = 
 var contribution = FORMAT([SalesAmount Color contribution], "0.0%")
 var contributionAdditive = FORMAT([SalesAmount Color contribution additive], "0.0%")
 return
 contribution & " (" & contributionAdditive & ")"

The measure SalesAmount Color contribution:

SalesAmount Color contribution = 
DIVIDE( [SalesAmount (ms)] , CALCULATE( [SalesAmount (ms)] , ALL( 'DimProduct'[ColorName] ) ) )

And the measure that sums the ordered percentage values:

SalesAmount Color contribution additive = 
VAR filtervalue =  [SalesAmount Color contribution rank]
var currentCategory = SELECTEDVALUE( 'DimGeography'[ContinentName] )
return
SUMX(
    FILTER(
        ADDCOLUMNS(
            ADDCOLUMNS(
                SUMMARIZE(
                    ALLSELECTED( 'FactOnlineSales' )
                    , DimGeography[ContinentName]
                    , 'DimProduct'[ColorName]
                )
                , "v" , [SalesAmount Color contribution]
            )
            , "r" , 
                RANK(
                    DENSE
                    , ADDCOLUMNS(
                        SUMMARIZE(
                            ALLSELECTED( 'FactOnlineSales' )
                            , DimGeography[ContinentName]
                            , 'DimProduct'[ColorName]
                        )
                        , "v" , [SalesAmount Color contribution]
                    )
                    , ORDERBY( [v] , DESC )
                    , DEFAULT
                    , PARTITIONBY( 'DimGeography'[ContinentName] )
                )
        )
        , [ContinentName] = currentCategory && [r] <= filtervalue
    )
    , [v]
)

I’m really amazed by these new capabilities of the “stacked” data visualizations, and will start of updating some of the visuals I’m responsible of, the reason: I want to reduce system complexity.

 

There is one feature between this amazing bunch of new capabilities that I ask you to handle with care, this feature is “Space between series” and allows to create a data visualization that looks like the one below (you will find this property on the Layout card of the Bars section):

Being honest, I find the spaces between the segments aesthecially pleasing, but i think it’s important to watch for the informational impact this white space has, especially if there is an axis with a continuous scale.

 

Nevertheless, Stacked bar charts rule!

 


Thank you for reading.

Kommentar schreiben

Kommentare: 0