Two axis column chart with a total line.

RockandGrohl

Well-known Member
Joined
Aug 1, 2018
Messages
810
Office Version
  1. 365
Platform
  1. Windows
Hi

I have a clustered column chart laid out in the following structure:

Asset on the X axis.
Cost on the Y axis
Stage is Legend

The idea of the chart is to filter by project using a slicer, and then all the Assets (components) of the project are across the X axis grouped by Stage. This way, we can compare costs of assets as the project moves through the 5 stages. Hopefully that makes sense.

In order to compare the total project cost at various stages, I want to include a secondary Y axis which is a sum of the Project ID for each particular stage. I have been utterly unsuccessful in doing this.


Here's how the main table "Database" is laid out.

There are multiple rows per Project ID. Each row is an asset, which has a cost in the Cost column. The Project ID can have between one to five stages, so the same asset might be repeated more than once but each is assigned to a different stage.

What I've tried doing is dragging the Cost into the second Y axis column, but that just puts a squiggly line on the chart which follows the bars. I then created a measure to Sum Up the Total Cost like so:

Power Query:
Total Cost = CALCULATE(
    SUM('Database'[Cost]),
    ALLEXCEPT('Database', 'Database'[Project ID], 'Database'[Stage])
)

But this places a horizontal line on the chart which is a sum of both Stages. As an example, if Stage 1 is £130k and stage 2 is £150k then I want two horizontal lines on the chart, one at £130k and one at £150k. The above DAX creates one line at £280k.


The only way I've found this to work is to create 5 measures to sum each Project ID for each gateway, and then stack them together in the secondary Y-axis, like this:

Power Query:
Stage1Cost = 
CALCULATE(
    SUM('Database'[Cost]),
    'Database'[Stage] = "Stage 1"
)

etc from 1 through 5.

However, the caveat here is that it creates 5 additional items on the legend, whether the project has 1 stage or 5. But visually, the lines do go in the correct place on the chart.


I'm wondering if anyone can help? ChatGPT has been absolutely useless. Thank you.
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type

Forum statistics

Threads
1,224,804
Messages
6,181,057
Members
453,015
Latest member
ZochSteveo

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top