Introduction: Why Aligning Charts with Tables in PowerPoint Matters
Recently, I was in touch with a market research firm which has a huge slide repository. While most of their slides could be automated with SlideFab right away, one slide layout seemed difficult. In fact, dynamically aligning the data points of a chart exactly in the middle of a table row was not possible on the first peek. So the task is about how to align a vertical line chart to a table. Basically, a very similar layout to the one from a previous blog post about automating Likert charts:

However, the key difference was that the number of rows ought to be dynamic and still fill the slide height. While this is no challenge for the chart, the data table needs to have a variable row height. Therefore, SlideFab v.10.0 introduced the ability to stretch the table to its initial height after removing empty rows. This tutorial will explain how this feature allows it to align a vertical line chart to a table perfectly. Above all, perfectly means here that each data point lies vertically in the middle of a table row. This is the only it looks decent when the rows have alternating colours as background or borders in between each pair of rows.
Overview
This tutorial starts with sales data obtained from the AdventureWorks fictional database. First of all, we will prepare the chart and data table in Excel. Secondly, we will create a PowerPoint template slide with an initial table and a linked chart. Finally, we will use SlideFab to connect Excel with PowerPoint and automate the creation of these slides with aligned vertical line charts and tables.
This tutorial is rather long as it goes into much detail on the creation of the Excel workbook.
What is required for this tutorial on How to align a vertical line chart to a table in PowerPoint and make it dynamic regarding number of rows
Of course, we need SlideFab. For this example the free version SlideFab Lite is sufficient.
A PowerPoint presentation serves as template
This tutorial will start with a rather empty PowerPoint presentation containing just one slide. The preparation steps follow later on.

An Excel workbook will be connected with the PowerPoint template presentation
The Excel workbook used for this tutorial is lean. For instance, it contains only one worksheet with a data table. This data is about sales by category and country over time.

To create the combination slides with vertical line chart and table using SlideFab, follow these steps.
This tutorial involves a larger number of steps. However, most of these steps are related to creating the Excel workbook and the PowerPoint template. SlideFab comes into play towards the end.
Time needed: 30 minutes
- PART 1: Creating the Excel workbook with the chart and table calculations
An important note upfront: The sales data comes within a table called
Data
. When referencing columns within this table in a formula, Excel puts the column names in brackets. So for example,Data[SalesTerritory.Country]
refers to all data from theSalesTerritory.Country
column within the table calledData
. - Obtaining the country list
– Open the Excel workbook.
– Create a new worksheet.
– Add the category list using the formula below.=UNIQUE(Data[Product.Category])
- Getting the count of subcategories for each category
This step helps here to determine the maximum number of rows for the table in PowerPoint. This tutorial leaves out the case where there is more data than rows. For these cases there is an explanation on how to distribute the data across multiple slides.
Use the following formula to determine the number of subcategories per category:=BYROW(B4#,LAMBDA(category,COUNTA(UNIQUE(FILTER(Data[Product.Subcategory],Data[Product.Category]=category)))))
It works as follows. TheBYROW
function is applied to the list of categories. After that, it applies theLAMBDA
function to each category of this list. Within theLAMBDA
function a mereCOUNTA
counts the number ofUNIQUE
subcategory entries. TheFILTER
function makes sure that only subcategories from the current category (with respect to theLAMBDA
function) are counted. - Calculating the relative margin per category
With the category list in place, the actual data gets into the focus. In particular, the line chart shall show the category margin in percent as comparison. So we divide the margin in absolute terms by total sales. The
SUMIFS
functions does the job for each category.=
SUMIFS(Data[Margin abs],Data[Product.Category],B4#)
/SUMIFS(Data[Sales Amount],Data[Product.Category],B4#))
Add this formula to the worksheet to calculate margin % per country and month. - Defining the Master Cell
For the iteration loop over the categories the Master Cell will hold the current category. Therefore, we just enter one of the categories here to make the subsequent creation of the workbook easier.
- Looking up relative margin for current category
We will merely lookup the relative margin from the range calculated before:
=XLOOKUP(G4,B4#,D4#)
Of course, calculating it with SUMIFS based on the raw data here is an equally sound idea. - Getting the subcategory list for the current category
As the objective is to show the margin % per subcategory, we look up the subcategories first of all:
=SORT(UNIQUE(FILTER(Data[Product.Subcategory],Data[Product.Category]=G4)))
- Calculating the relative margin per subcategory
With the list of subcategories in place it is simple to obtain the relative margin of each:
=
SUMIFS(Data[Margin abs],Data[Product.Category],G4,Data[Product.Subcategory],J4#)
/SUMIFS(Data[Sales Amount],Data[Product.Category],G4,Data[Product.Subcategory],J4#)
It is done in a similar fashion as before for the category by usingSUMIFS
. - Creating the chart data, first a helping row number
First of all the row subcategory number for the given category will be calculated. This is optional as it is not used by any other formula subsequently in this tutorial.
=SEQUENCE(ROWS(J4#))
- Calculating the vertical position of each subcategory data point in the vertical line chart
This is a really important step of the tutorial as it calculates the vertical position for each data point between values of 0 and 1. Reason for this is that the chart Y axis determines its lower and upper boundaries based on actual data values. However, this is impossible to predict, so fixing the lower and upper boundaries to constant values becomes inevitable. We chose the values 0 and 1 here because this way it is easier to calculate.
=LET(countOfRows,ROWS(J4#),SEQUENCE(countOfRows,,1/(countOfRows)*0.5,1/(countOfRows)))
This formula also takes into account that both the first and the last data points will be in the middle of a table row. - Getting relative margins per subcategory from before as X axis values.
For the chart data area we will merely get the relative margins per category as calculated before.
- Getting Y position for category comparison line.
For the comparison line it is possible to use the Y values as before. However, this might look odd as the data points for the subcategory series are supposed to be position in the middle of each row. Instead, we want to have a vertical comparison line which reaches from the topmost area of the chart to the bottommost. Accordingly, we create the Y axis values in a straight forward way starting at Y=0 reaching to Y=1:
=LET(countOfRows,ROWS(J4#),SEQUENCE(countOfRows,,0,1/(countOfRows-1)))
- Getting relative margin of category as X axis values.
For the comparison line, we need the same X value for all rows. This makes sure that the comparison line will be vertical:
=SEQUENCE(ROWS(J4#),,H4,0)
IMPORTANT (as not shown in the screenshot). The header row (in the screenshot cell R3) contains a concatenation of text and the current category name:="Category: " & G4
- Adding some helping numbers to easily create the data range for the scatter plot chart later on.
This step is optional. It helps to clearly see how over how many rows the data for the chart might stretch.
- Creating a scatter plot chart with lines and markers
- Setting X and Y value data ranges for the subcategory series
To have the series for the subcategories in place, we set up the series as follows. The calculated Y axis values needs to be set as series Y values and the relative margins as series X values.
- Setting X and Y value data ranges for the category comparison line
Also for the category comparison line we set up the series in the same way. Consequently, the calculated Y axis values need to be set as series Y values and the category margin as series X values.
- Setting up the chart Y axis
As explained above, we calculate the Y axis values in an interval between 0 and 1. Accordingly, the automatic bounds calculation needs to reflect these values instead of the automatic setting. Additionally, we need to reverse the Y axis as the first row has the value 0 (and not 1). The last setting we apply here is to set the Axis Crossing to the Maximum axis value instead of Automatic. This makes sure that the X axis labels are at the bottom of the chart.
- Fine-tuning the chart area for proper looks
So far the X axis values showed decimals. As the margin is a percentage value this needs to be changed here, too. Additionally, it is necessary to hide the markers from the comparison line and to make some room at the top of the chart for a helpful data label (see below).
- Creating the Data Label for the topmost data point
Select the topmost data point and right click and hit Add Data Label.
- Formatting the Data Label
The Data Label we position above the data point and switch to Series Name instead of some value. This way it is always clear what the meaning of the vertical comparison line is.
Note: Setting the Data Label for the topmost data point is the only way it makes sense here. The topmost data point will be always there no matter how many rows (at least 1, of course) the chart will show. To have the Data Label at the bottom the Y axis must not be reversed and the Y axis values have to be decreasing from 1 to 0. - Creating the labels for the data table
The first column of the data table is supposed to contain the subcategories. We merely take the labels from before.
- Getting and formatting the margin % per subcategory for the data table
The
TEXT
formula helps to format the relative margin as percentages:=TEXT(K4#,"0.0%")
- Adding some helping numbers to easily select the range for the data table later on.
This step is optional. It helps to clearly see how over how many rows the data for the table might stretch.
This step completes the Excel workbook. - PART 2: Creating the perfectly aligned table and vertical line chart combination in PowerPoint
- The target for the automation is a slide in a PowerPoint presentation with a fixed title.
- Adding a table to the template slide
– Choose the insert tab in the PowerPoint ribbon
– Hit “Insert Table”
– Create a table with 3 columns and 15 rows. As 14 is the maximum number of data points / rows for this example, the 15th row is for the header. The 3 columns here are for category name, margin % and mere background for the chart. - Setting Cell Margins to narrow to allow reducing row height
- Removing all cell borders.This is superfluous due to banded rows of the table.
- Setting the vertical alignment to have the texts in the table properly align with the data points of the chart.
- Linking the PowerPoint template presentation with the Excel workbook
– Open the SlideFab tab in the ribbon.
– Click the small chevron (down angle) button where it says “Excel: Closed”.
– Choose either of the first three entries:
— “Select and Open Excel file” will let you browse the hard drive for the Excel file.
— “Open Excel file” will re-open an existing file, if there had been one already. If not, it has the same effect as the one mentioned before.
— “Try to use currently open Excel workbook” will try to establish a connection with the Excel workbook which was active most recently. - Copying and pasting the vertical line chart from Excel to the PowerPoint slide
This way the pasted chart still has the connection to the Excel data.
- Aligning the vertical line chart and the data table
– Put the vertical line chart in front of the table (ensure that chart is fully in front)
– Use the Y axis bounds of 0 and 1 to perfectly align with the upper and lower edge of the first and of the last data row. - Removing Y axis and horizontal lines from the chart
- Adding manual table headers and colouring the Data Label of the chart accoringly
- Connecting the Excel data table range with the table on the PowerPoint template slide
– Select the range containing the table data all the way to down to the last row in which we expect data.
– Select the target table in PowerPoint
– Click the cross hair icon in the “Excel Source Range” to define the link. SlideFab will write the address of the selected range into the control field.
– Set the “Start Row in PPT table” to 2. This will preserve header row in the PowerPoint table.
– Enable “Remove Empty Rows”.
– Enable table stretching with the setting “Start row and below” which will make sure that SlideFab stretches data rows only. The header in row 1 will remain as defined. - Just a reminder: The pasted chart in PowerPoint is already set up for automation.
- PART 3. Setting up the iteration loop
So far we built the Excel workbook and the PowerPoint template slide. We also linked the vertical line chart as well as the table. The only thing missing is setting up the automation for creating multiple combined vertical line chart with table.
- Setting up the Candidate Range for the category rows
– Select the column with unique identifiers (here the category name is a unique identifier for each worksheet).
– Open the Iteration Loop side pane via the ribbon.
– Click the crosshair icon in the “Loop Candidate Range” control to define the link. SlideFab will write the address of the selected cells into the control field. - Setting up the Master Cell for the current category name
– Select the cell into which one value (i.e. category name) from the Candidate Range shall be written.
– Click the crosshair icon in the “Loop Master Cell” control to define the link. SlideFab will write the address of the selected cell into the control field. - Running the automation
– Click the “Make Slides” button in the SlideFab tab of the Powerpoint ribbon to open up the actual window for this.
– When hitting the “Start” button, SlideFab will run the automation. It will work even without an Iteration Loop using the current state of the Excel workbook. - Waiting some brief moments until the slide automation completes.
- Rerun the slide making automation as explained above and check the output.
Perfect. The created combination slides with vertical line chart and table are precisely aligned.
- The closeup of one of these slides reveals that the data points are exactly in the middle of each row.
Summary of this tutorial on how to align a vertical line chart to a table in PowerPoint
This tutorial explained how to align a vertical line chart to a table in PowerPoint. The key aspect here was the scaling of the Y axis to reach from 0 minimum to 1 maximum instead of automatic adjustment. The automatic adjustment would have delivered unpredictable Y axis scalings. Instead the fixed bounds of 0 and 1 allowed it to position every data point in the middle of its table row. Apart from this the new feature to stretch the table to its original height brought the flexibility to have the table and the chart keep filling the slide.
FAQ
No, a bar chart has categories (labels) for each row. There is no option to set the Y axis position.