cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper III
Helper III

Adding a different value op top of a bar in a bar chart.

Hey everyone, short question.

 

I have a bar chart that looks like the following (see image below):

The grey bar is a measure.

The green bar is sum(table1[column 1]) 


What I would like to achieve, is to add sum(table 2[column 1]) to the other bar from table 1 (as illustrated), and have both in different colour.

I know there is a visual for a stacked bar chart, but that one stacks both the grey and green line. I think I have to use the legend to differenciate which bars belong together, but since the data is from different tables im not sure how I can achieve this.

 

image.png

 

thanks!

 
1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Adding a different value op top of a bar in a bar chart.

Hi @ErikBI ,

 

You need to create a workaround to have this made:

  • Create a measure for the calculation of table 1 and table 2:
Table1_Value = SUM(Table1[Value])

Table2_Value = SUM('Table 2'[Value])
  • Create a table with the names you want on the x-axis in my case I made this table:
Measure
A
B

 

  • Add the following two measure to use on your chart:
SelectionTable1_Values = SWITCH(SELECTEDVALUE('Table'[Measure]);"a";[Measure];"b";Table1[Table1_Value])

SelectionTable2_values = SWITCH(SELECTEDVALUE('Table'[Measure]);"b";'Table 2'[Table2_Value])

 

  • Create a Stacked bar chart with the following format:
    • Axis - MeasureColumn (from the table we created)
    • Values:
      • SelectionTable1_Values
      • SelectionTable2_Values

Check result below and in attach PBIX file.

measures.png

 

Measure is just a simple one that I calculated to sum all values on table 1 below 40.000 (you can use your own).


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

4 REPLIES 4
Highlighted
Super User III
Super User III

Re: Adding a different value op top of a bar in a bar chart.

Hi @ErikBI ,

 

To achieve this you need to have some relationship between the two tables, how is the values from table 1 and table 2 related?

 

Is the Axis values in common between both tables?

 

Do you want to have a 2 bar with 2 colour (measure one colour Table1+Table2 another colour) or 2 bars 3 colours (measure one colour Table1 one colour Table2 one colour)

 

Can you share some sample data for the measure and both tables?


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





Highlighted
Helper III
Helper III

Re: Adding a different value op top of a bar in a bar chart.

Hey Felix,

 

Sorry for the late reply. Been on and off for a while.

 

The x values are all the same (euros). 

 

In my previous example. Table 1 is the green bar. Measurue 1 is the grey bar.

I would like to add table 2 to the green bar of table 1, but with a different color.

 

Hope it makes sense now! 🙂

 

image.png

 
 

image.png

 

 

Highlighted
Super User III
Super User III

Re: Adding a different value op top of a bar in a bar chart.

Hi @ErikBI ,

 

You need to create a workaround to have this made:

  • Create a measure for the calculation of table 1 and table 2:
Table1_Value = SUM(Table1[Value])

Table2_Value = SUM('Table 2'[Value])
  • Create a table with the names you want on the x-axis in my case I made this table:
Measure
A
B

 

  • Add the following two measure to use on your chart:
SelectionTable1_Values = SWITCH(SELECTEDVALUE('Table'[Measure]);"a";[Measure];"b";Table1[Table1_Value])

SelectionTable2_values = SWITCH(SELECTEDVALUE('Table'[Measure]);"b";'Table 2'[Table2_Value])

 

  • Create a Stacked bar chart with the following format:
    • Axis - MeasureColumn (from the table we created)
    • Values:
      • SelectionTable1_Values
      • SelectionTable2_Values

Check result below and in attach PBIX file.

measures.png

 

Measure is just a simple one that I calculated to sum all values on table 1 below 40.000 (you can use your own).


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

Highlighted
Helper III
Helper III

Re: Adding a different value op top of a bar in a bar chart.

Hey Felix,

 

First of all, my apologies for replying to you so late. I've been working on and off this project and it got put aside for a bit.

 

At first I was a bit confused by how you calculated the "a' bar by exlcuding the 44k. But after digging through your example file I managed to understand the method that you used to create the graph and I managed to get it working!

 

Thanks so much for your help!

 

Here is what my end result looks like now:

1.png

Helpful resources

Announcements
Meet the 2020 Season 2 Power BI Super Users!

Meet the 2020 Season 2 Power BI Super Users!

Find out who's part of the program this season, and welcome the new Super Users.

August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Featured Data Story of The Month

Featured Data Story of The Month

All Data Stories Gallery contributions are reviewed for each month. We select a contribution and feature the community member the following month.

Power BI Dev Camp - Developing with .NET Core

Power BI Dev Camp - Developing with .NET Core

Learn how to develop custom web applications for Power BI using .NET Core 3.1 and .NET 5.

Top Solution Authors
Top Kudoed Authors