Forum Discussion

AhmadBakr's avatar
AhmadBakr
Icon for Helper IV rankHelper IV
1 year ago
Solved

Dynamic formatting not working with stacked bar chart total labels

I am using a stacked bar chart displaying a amounts on the x-axis. as the amounts range is huge, I used for the measure formatting a dynamic format to display amounts in Billions/Millions/Kilos or simple decimal numbers.

 

Data labels use the same measure as the bars, and formatting shows as expected. However, Total labels does not reflect the dynamic formatting as it should. Display units value formatting for both the Data label and Totals label are set to none already.

Screen shots below. I noticed a similar Issue raised in 2023 and 2024 already! Links also below.



Dynamic measure formatting (preview) not displayin... - Microsoft Fabric Community
Dynamic formatting issue with total label in bar c... - Microsoft Fabric Community

  • kushanNa's avatar
    kushanNa
    1 year ago

    Oh, I see. How about trying to overlay two stacked bar charts as a temporary solution?

    Create two stacked bar charts:

    • One with the legend

    • One without the legend

    Enable totals in both charts and position the totals at the outer edge.

    In the chart with the legend, make the total value's color transparent using the following code.

    Transparent = "#FFFFFF00"

     

    At the bottom chart , you can make the bar colors transparent 100% .

    The end result should look like this:

     

     

     

11 Replies

  • Hi AhmadBakr 

     

    While you can use a different measure as a data lable for the individual stacks, the total label uses the actual measure in the bars. Using a different one on the total isn't currently supported. 

    • AhmadBakr's avatar
      AhmadBakr
      Icon for Helper IV rankHelper IV

      Hi danextian, exactly.

      In fact I tried it, and what u mentioned was the case.

       

      Interesting enough, I went to do some experiments with the sample data table I shared, I discovered that I the data of the first series (the firs legend point) is in the K order, and the total is in the M order, the problem happens! As if the totals are calculating the format from the dynamic format of the first series!

       

      This is not final yet, but I noticed it while exploring this issue.

      • danextian's avatar
        danextian
        Icon for Super User rankSuper User

        Did you perhaps change the display units of the total labels to thousands?

  • Below is fictitious data in a table to illustrate the case.

     

    Use it in a clustered chart (column or bar):

    • Put Cat on the category axis: Y-axis if bar chart, X-axis if column chart
    • Series in the legend
    • Value in the value axis: X-axis if bar chart, Y-axis if column chart

     

    use the following measure:

    sumtest = SUM(Formatting[Value])
     
    Format this measure as dynamic, and use the below for the dynamic formatting code:
    VAR val = SELECTEDMEASURE()
    VAR k = 10^3    VAR m = 10^6    VAR b = 10^9
    RETURN
        SWITCH(TRUE(),
            val >= b, "#,##0,,,.00B",
            val >= m, "#,##0,,.00M",
            val >= k, "#,##0,.00K",
            "##0.00"
        )
     
    Show Data Labels and Total Labels
    Format Display units for values of Data Labels as "None"
    Format Display units for values of Total Labels as "None"


    Table Name: Formatting
    Cat    Series    Value

    AX1234567
    BX5234567
    CX2345635
    DX123463
    AY2087654
    BY2654321
    CY467375
    DY3219768
    AZ7098765
    BZ3456721
    CZ2222467
    DZ1114674

     

    The below is the result!



      

     

     

    • kushanNa's avatar
      kushanNa
      Icon for Super User rankSuper User

      Hi AhmadBakr 

       

      I couldn’t dig deep into the issue you're facing, but a quick workaround I can suggest for the stacked column chart is to use a Line and Stacked Column Chart and set the line label as the total.

      Once you create the line, make its color 100% transparent.

      For the data labels, set the display units of all series to None, but keep it as Auto only for the specific measure.

       

       

       

       

       

      • AhmadBakr's avatar
        AhmadBakr
        Icon for Helper IV rankHelper IV

        Hello kushanNa. Thank you for your response.

         

        Yes, I thought of the same, however unfortunately I am using a stacked bar chart in my report, hence the fix I am in! I included in my demo a stacked column chart in addition to the bar chart to show the problem is with the stacked charts in general, as it appeared to me.