Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Total Column in a Clustered Bar chart

Hi,

To get a Total Bar in a clustered column chart.

Need a total bar along with the four bars as shown in the below image.

Santho_BI_0-1695368578074.png

Thanks in advance.

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @Anonymous 

You can refer to the following example

Sample data

vxinruzhumsft_0-1695796519115.png

 

1.Create a new Type table

Type = var a=SUMMARIZE('Table','Table'[Year_Month])
var b={"Total"}
return UNION(a,b)

2.Then create a measure to calculate the sum

Sum =
VAR a =
    SUMMARIZE ( FILTER ( 'Type', [Year_Month] <> "Total" ), [Year_Month] )
RETURN
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Year_Month] IN a )

3.Then create a measure

Sum_display =
VAR a =
    SUMMARIZE ( ALLSELECTED ( 'Type' ), [Year_Month], "Sum", [Sum] )
RETURN
    IF ( SELECTEDVALUE ( 'Type'[Year_Month] ) = "Total", SUMX ( a, [Sum] ), [Sum] )

4.Put the column of type table and the sum_display measure to the visual

Output

vxinruzhumsft_1-1695796695399.png

Best Regards!

Yolo Zhu

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

 

View solution in original post

5 REPLIES 5

@v-xinruzhu-msft  Can you please let me know how to get total column for running total. I tried this method for running total and its not working

v-xinruzhu-msft
Community Support
Community Support

Hi @Anonymous 

You can refer to the following example

Sample data

vxinruzhumsft_0-1695796519115.png

 

1.Create a new Type table

Type = var a=SUMMARIZE('Table','Table'[Year_Month])
var b={"Total"}
return UNION(a,b)

2.Then create a measure to calculate the sum

Sum =
VAR a =
    SUMMARIZE ( FILTER ( 'Type', [Year_Month] <> "Total" ), [Year_Month] )
RETURN
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Year_Month] IN a )

3.Then create a measure

Sum_display =
VAR a =
    SUMMARIZE ( ALLSELECTED ( 'Type' ), [Year_Month], "Sum", [Sum] )
RETURN
    IF ( SELECTEDVALUE ( 'Type'[Year_Month] ) = "Total", SUMX ( a, [Sum] ), [Sum] )

4.Put the column of type table and the sum_display measure to the visual

Output

vxinruzhumsft_1-1695796695399.png

Best Regards!

Yolo Zhu

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

 

Any idea how to get this to sort correctly when working with a full year since you'll have 2023-1 and 2023-10 and BI will format the "Year_Month" column in the "Type" table as text? Also, if it could be scalable to include future years, that would wonderful.  Great solution otherwise though!

Thank you for providing the example and steps you've taken to create a clustered column chart with a total bar in Power BI. It looks like you've already created the necessary measures and set up your visual correctly. Here's a summary of the steps you've taken:

  1. Created a new table called "Type" with a "Total" category.
  2. Created a measure called "Sum" to calculate the sum of values excluding the "Total" category.
  3. Created a measure called "Sum_display" to display the sum values and handle the "Total" category separately.
  4. Placed the "Type" table and the "Sum_display" measure in the visual.

Your output appears to be a clustered column chart with the "Total" bar included, which is exactly what you were looking for. This approach is common in Power BI for displaying a total bar in a clustered column chart.

If you have any specific questions or need further assistance with this Power BI setup, please feel free to ask, and I'll be happy to help.

 
 
 
123abc
Community Champion
Community Champion

To add a total bar to a clustered column chart in Power BI, you can follow these steps:

  1. Create Your Clustered Column Chart:

    • Start by creating a clustered column chart with your data.
    • Place the relevant fields in the "Axis" and "Values" sections of the visualizations pane to create your clustered bars.
  2. Calculate the Total:

    • You'll need to create a measure to calculate the total value that you want to display as a separate bar in the chart.

For example, if you want to calculate the total of a column called "Value," you can create a DAX measure like this:

 

Total Value = SUM(YourTableName[Value])

 

Replace YourTableName with the actual name of your table and Value with the name of the column you want to total.

  1. Add the Total to the Chart:

    • Now, drag and drop the "Total Value" measure you created in step 2 into the "Values" section of your clustered column chart in the visualizations pane.
  2. Format the Total Bar:

    • By default, the total bar may appear as another clustered column within your existing clusters. To make it a separate total bar, you'll need to format it.
    • In the "Visualizations" pane, click on the chart to select it.
    • In the "Format" section, expand "Data labels" and turn off the "Data label" option. This will remove labels from the total bar, making it look cleaner.
    • You can also format the total bar's color and style to distinguish it from the other bars if needed.
  3. Adjust Axis and Scales:

    • Depending on your data, you may need to adjust the axis and scales to ensure the total bar doesn't skew the visualization. You can do this in the "Format" section under "Axis" and "Y-Axis."

Now, your clustered column chart should include a separate total bar alongside the clustered bars, displaying the total value you calculated. You can further customize the appearance of the total bar to match your desired chart aesthetics.

 
 
 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.