
In this guide, we’ll see how to create a dynamic chart in Excel. Specifically, we’ll create a chart with a dynamic data source that updates in real time by leveraging Excel for Microsoft 365 functions that allow us to return multiple values from a single cell using the # (Dynamic Array) syntax, such as FILTER and XLOOKUP. Unfortunately, the file is not compatible with earlier versions of Excel, but you can also use it in Excel Online (you can sign up for free on the official Microsoft website).
You can download the final file by clicking the button below:

These are the interactive elements needed to create the dynamic chart; we’ll go over them in detail throughout this guide:
- Initial starting table
- Supporting table for using the slicer
- Summary of the information to include in the chart with FILTER, XLOOKUP, etc.
- Dynamically creating the title to associate with the chart
- Creating the chart
- Defining the name for the first array (values per agent)
- Defining the second name for the second array (the years)
- Setting conditional formatting rules
Let’s get started!
Starting table for creating a dynamic chart in Excel

In this case, we have a fairly simple table containing the following:
- AGENT: These are the names of the agents we are considering for the analysis
- 2018, 2019, 2020, 2021, 2022: these are the years with individual revenue figures
As we can see, some of the agents joined the company later (Bonomi, for example, joined in 2020) or left the company (Berardi, who is not listed in 2022). This is important for explaining some of the adjustments we’ll need to consider in the final stage of creating the chart.
Creating the supporting table for the dynamic chart in Excel

For now, we only have our initial table, named TBL_SALES. However, let’s create another table named TBL_SUPPORT that reflects the following:
- AGENT: these are the names of the agents listed above
- SUBTOTAL: This is a helper column that we’ll use to correctly identify the value to be entered into the chart
The SUBTOTAL function allows you to perform calculations based solely on visible cells, so it’s perfect for this scenario since we’ll need to filter the table’s results.
In this case, as we can see, we apply it to all rows in the SUBTOTAL column as follows:
=SUBTOTAL(3,[@AGENT])
SUBTOTAL returns various functions depending on what we need; in this case, we’ll use the first one (3) because it will count the values for us for each agent. Currently, the calculation it performs is to take each agent and return 1, since none of them appear more than once in the table; however, when we filter using the slicer, it will allow us to identify the specific agent we’re interested in. This trick was inspired by Carlos Barboza, whom I highly recommend you follow on LinkedIn if you’re learning how to create particularly complex visualizations in Excel.
Note: The supporting table is aligned with the previous one solely for the sake of simplicity in explanation; I recommend placing it below the original table to avoid “strange” visualizations later on
Creating the supporting structure to extract the information to be included in the Excel chart
Let’s now move on to creating the individual parts we’re interested in. Specifically, we’ll need to determine:
- Name of the agent we are considering
- Revenue values for the agent we are considering
- Reference years for the agent we are considering
- Create a dynamic title that we’ll reuse for the chart
As mentioned above, the agents have different years of experience, so we’ll need to account for this in the formulas.
Let’s see how to find each of these using formulas:
How to find the agent’s name from the Excel table

In this case, we’ll use the XLOOKUP function to find the reference value. Specifically:
=XLOOKUP(1,TBL_SUPPORT[SUBTOTAL],TBL_SUPPORT[AGENT])
The function searches for the value 1 within the supporting table in the SUBTOTAL column and then returns the value AGENT. If there are no filters, it will return ROSSI since that is the first result found in the table. The same result can be replicated (in versions prior to Excel for Microsoft 365) using the combination INDEX MATCH.
How to Find the Years of Service for an Individual Agent

In this case, we’ll use the formulas provided by Excel for Microsoft 365 to find the years we’re interested in:
=FILTER(TBL_SALES[[#Headers],[2018]:[2022]],INDEX(TBL_SALES[[2018]:[2022]],MATCH(I5,TBL_SALES[AGENT],0),MATCH(TBL_SALES[[#Headers],[2018]:[2022]],TBL_SALES[[#Headers],[2018]:[2022]],0))>0)
This function is significantly more complex than the previous one, but essentially, it filters the years, returning only those cases where a combination of the years and the individual agent yields a value greater than 0. Let’s look at it in detail:
- FILTER allows us to filter the results; in fact, at the end of the function, we find a >0. This means that we will filter the results of the subsequent table lookup using INDEX MATCH MATCH, retrieving only the years in which the generated revenue is greater than zero
- INDEX MATCH MATCH allows us to search the table. So when we enter INDEX(TBL_SALES[[2018]:[2022]], we’re telling Excel that we want to get the individual years as the result, provided that MATCH(I5,TBL_SALES[AGENT],0), (the agent is the one specified in I5, in this case Rossi) and that MATCH(TBL_SALES[[#Headers],[2018]:[2022]],TBL_SALES[[#Headers],[2018]:[2022]],0)) (the years are those indicated in the source table). Excel then performs a lookup by cross-referencing rows and columns, returning only the values from the row corresponding to Rossi for all years in the source table. Finally, as mentioned, FILTER will remove values less than zero, allowing us to work exclusively with the years of activity for each agent
This function gives us 5 results for Rossi, 3 for Mazza, 4 for Berardi, and so on. The formula is entered in cell J3.
How to Find Revenue Values by Individual Agent

Clearly, we want to populate the table with values for each agent. We can do this by using the FILTER function, in this case in combination with XLOOKUP:
=FILTER(XLOOKUP(I5,TBL_SALES[AGENT],TBL_SALES[[2018]:[2022]]), XLOOKUP(I5,TBL_SALES[AGENT],TBL_SALES[[2018]:[2022]])<>"")
As before, the two formulas perform a specific task:
- FILTER filters the results, retaining only those cases where the result of XLOOKUP is not blank. This is because we consider blank values to represent years of inactivity for the individual agent
- XLOOKUP searches for the value in cell I5 (in this case, “Rossi”) within the source table and returns all values from columns 2018 through 2022, provided that (this is where FILTER comes into play) the revenue is not empty
As we can see, in this case the formula returns 5 values, but it will return fewer for agents who were not active for all 5 years. The formula is entered in cell J5.
How to Create a Dynamic Title for an Excel Chart

Our goal is to add a dynamic title to our Excel chart. To do this, we’ll use a combination of formulas to generate the desired text, which includes both static and dynamic parts:
=CONCAT("The total for ",I5," over the ",COUNTA(J5#)," anni considerati is pari a ",TEXT(SUM(J5#),"€#,##0"))
In this case, the steps are as follows:
- CONCAT allows us to concatenate multiple text values into a single cell
- COUNTA counts the values entered in the array J5#. If you’ve never seen the # symbol before, it indicates formulas called Dynamic Arrays (FILTER, XLOOKUP, UNIQUE...) created with Excel for Microsoft 365 that fill multiple cells starting from a single one
- TEXT improves the final formatting of the title, allowing us to add the Euro symbol and the thousands separator
- SUM calculates the total of the previous revenue values, again using the array hash symbol J5#
At this point, all that’s left is to create the slicer, create the chart, and link everything we’ve created so far to build the dashboard.
Insert a slicer into the Excel source table

Let’s now return to the source table. Click anywhere in the table and go to Table Design > Insert Slicer to create the slicer, which will serve as our dynamic button for the dashboard. Clearly, the entry we’re interested in is AGENT and not SUBTOTAL, since we use SUBTOTAL exclusively for calculations.
Note: As mentioned earlier, it’s best to move the supporting table to the bottom of the sheet since it’s not needed for visualization, as you can see, it now starts at cell B29. To cut and paste the table, simply press CTRL + X and then CTRL + V at the desired location.
The result should be, excluding the formatting (which you can change using the slicer styles), a view like this:

If you want to change the number of columns, you can click on the slicer and then go to the context menu at the top and select Slicer > Buttons.
Creating a Dynamic Chart with Excel

Now all that’s left is to create the chart. Select the data starting from J3 (for the years) and J5 (for the revenue values), then go to Insert > Recommended Charts.
At this point, you should have a standard chart like this:

Since we’re looking at a time span of several years, we can select the chart, then click on Chart Layout > Change Chart Type and select a line chart (it’s up to you, it’s just for better visualization). From here, all that’s left is to add the title, which is done as follows:

Essentially, you need to select the chart title field > leave the chart title blank > select the formula bar and enter =(cell_with_the_title). In my specific case, I had moved the result to cell P13 on my worksheet named DB, so it appears as =DB!$P$13. If, on the other hand, your sheet were named DB_SALES and the cell were Q7, the result would be =DB_SALES!$Q$7. This way, we’ll have a dynamic title that changes depending on what we select from the slicer.

As we can see, the label is now exactly the same as cell P13. We are therefore able to dynamically change the label, adding flexibility to our model.
How to Dynamically Modify the Data Set in Excel
There’s just one key point missing. Currently, our chart uses all values starting from J3 onward, as well as those starting from J5 onward. So if we had selected “Mazza” and a line chart, the result would look something like this:

As we can see, in this case the chart looks distorted because two years were missing. To fix this problem, we need to perform a few final steps before finishing, and we’ll make the most of the arrays we created earlier.
We need to rename our arrays so they have specific names. Click on cell J3, then go to Formulas > Define Name:

At this point, feel free to choose whatever name you prefer; in this case , I entered “chartYR ,” which refers to the years to be included in the chart. Be sure, however, to enter the entire array in the “Refers to” field by adding a # at the end, for example, using “=DB!$J$3#” instead of “=DB!$J$3”, otherwise the reference won’t work.

Next, repeat the procedure to retrieve the revenue values; again, choose whatever name you prefer, I entered “chartSRC,” which refers to the revenue values linked to the array J5#:

At this point, if you’d like, let’s modify the final chart with the following settings before continuing:
- Chart Format > Change Chart Type > Select the line chart
- Chart Design > Add Chart Element > Data Labels (Above)
- Make the title bold
- Chart Layout > Add Chart Element > Lines > Projection Lines
Select the chart again, and now make changes under Chart Structure > Select Data:

Now click Edit in the horizontal axis section, where we’ll enter the year values:

Replace the entered values and link the array we created earlier with the years, in my case, `chartYR`, to make it dynamic. Be sure to also include `DB!$` or the specific worksheet you’re using, otherwise it won’t work:

Then repeat the process by clicking Edit in Legend Entries (Series):

To verify that we’ve followed all the steps correctly, we can click on the data within the chart. Notice how the source SERIES is now correctly labeled as chartYR and chartSRC:

At this point, we’re almost done! We can move the slicer above our previous calculations (since they’re not useful for our visualization anyway) and move the chart to the bottom. The final result will look something like this:

To add a final touch to our dashboard, we might want to highlight the reference row for each agent using conditional formatting.
Highlighting the Entire Row with Conditional Formatting in Excel
In this case, we need a little trick to highlight the entire row; specifically, we’ll use conditional formatting with formulas to quickly resolve the issue and improve the visualization. Remember that in this case, our agent is in cell I5.
Select the entire table (excluding the column headers) and click Conditional Formatting > New Rule:

Now we can set the rule so that if the value in column B ($B4, since it’s the first cell in the range that’s part of the table) is equal to I5, then the entire row should be filled with the same color:

And that’s it! We’ve created a dynamic dashboard that uses a variable data source; the chart updates in real time with the click of a single button, and we’ll also see the data shown on the chart displayed in real time on the left-hand side!

Conclusion
A slicer on the source table, SUBTOTAL and XLOOKUP pick the agent to show, and FILTER with INDEX and MATCH returns the data for the chart. The result is a chart that changes with one click, without macros.
You can download the final file by clicking the button below:
