A lesson is completed when you tick it, when you watch its video to the end or when you score 80% on its quiz. The certificate is issued online after the final assessment, from a score of 32 out of 40.
Lesson 12, module 4: Advanced features Python in Excel and the Analyst agent for analyses that formulas can't do Do hotels pay later than restaurants? A formula answers that poorly.
Python in Excel: code in a cell, calculated in the cloud. =PY or Formulas, Insert Python xl() reads a whole table Ctrl+Enter confirms the cell Copilot writes the code, you read it. Prompt: Analyse October sales with Python, by week and by customer, with a chart. Code commented in French. Answer: A PY cell: xl("Ventes[#All]", headers=True), ISO week, table of 7 customers × 5 weeks, total 8,071.00. Week 42 on top with €2,304.50 excl. VAT. Read the code before the result. [Diagram: From prompt to reviewed result] 1. Prompt 2. PY cell 3. Result 4. Reading the code 5. Control recalculation Read the code before the result: it's the code that tells you which rows were included. Week 40: €748. A weak week? No, two days of October. 1 and 2 October only 288.00 + 460.00 Reading the code showed it Hotels 20.5 days, restaurants 22 days. On two invoices each. Python gives a precise figure The sample allows no conclusion Formula, PivotTable, Python or Analyst: the simplest that answers. [Diagram: Formula, PivotTable, Python or Analyst?] 1. Does the question go beyond a sum, a count or an average per category? 2. Do you need a calculation formulas handle badly: matching two tables, statistics, a chart built by code? 3. Does the data fit in a single open workbook? Yes to all: Python in Excel: a PY cell, commented code that's been reviewed, a result that recalculates in the workbook. In the exercise, you analyse the basket at the Libourne shop. Your turn: The average basket at the Libourne shop The written lesson, the corrected exercise and the quiz are below the video.
Lesson 12 of 14 · module 4, advanced features
Python in Excel and the Analyst agent for analyses formulas can’t do
Python in Excel runs code in a PY cell, calculated in Microsoft’s cloud, and Copilot can write it for you in Edit mode. The Analyst agent, available only with a licence, analyses data in the Microsoft Copilot app. Both help when formulas struggle, provided you read the code and redo a total.
28 min of reading
1 min 51 of video
6 diagrams
3 demandes to copy
3 exemples pratiques
4 exercices answerss
5 questions
1 ressource
By the end of this lesson, you will know how to
Check that your plan and version include Python in Excel, then read a table with the xl() function
Have Copilot write a Python analysis commented in French, and check it line by line before trusting the result
Choose between a formula, a PivotTable, Python and the Analyst agent based on the question and the effort
What’s covered
What Python in Excel is
Have Copilot write the code
Do hotels pay later than restaurants?
The Analyst agent, when the data goes beyond the workbook
3 worked examples, followed from start to finish
Exercise with answers · Average basket at the Libourne shop
3 practice exercises, from guided to demanding cases
The quiz
Key points
Python in Excel is written in a PY cell, calculated in Microsoft’s cloud and reads the workbook through xl(), for example xl("Ventes[#All]", headers=True).
It works on Windows, Mac and the web, not on iPad, iPhone or Android; premium compute is capped each month.
When Copilot writes the code, you read it line by line, then redo a total with a formula.
The Analyst agent lives in the Microsoft Copilot app and requires a licence; it is useful when the data goes beyond one workbook.
A precise figure based on fourteen invoices is still only a lead: the simplest tool that answers the question is the right one.
Mathieu, head of the distributor in Mérignac, asks a question at the committee meeting: “Do hotels pay later than restaurants?” Answering it means matching two tables, Relances and Ventes, calculating delays at a given date and grouping by client type. It can be done with formulas, but it takes a long time. This lesson shows two tools built for this kind of analysis: Python in Excel, which Copilot can write, and the Analyst agent in Microsoft Copilot. It also shows why a precise figure is not always an answer.
What Python in Excel is
Python in Excel lets you write Python code directly in a cell. You turn it on from the Formulas tab, Insert Python button, or by typing =PY and choosing PY from the list. The code runs in Microsoft’s cloud, in an isolated container, with libraries provided by Anaconda: you need an internet connection, and nothing to install on your computer. The code reads the workbook through the xl() function: xl("Ventes[#All]", headers=True) takes the whole Ventes table, including the header row. The safest method is to select the table with the mouse while the PY cell is being edited: Excel writes the reference for you. Functions that read an external file, such as pandas.read_csv, do not work: the data comes from the sheet or from Power Query.
Who has Python in Excel (Microsoft page read on 19 November 2026)
Platform
Business and professional
Personal and Family
Windows
Current Channel from version 2408, Monthly Enterprise Channel 2408, Semi-Annual 2502
Preview, Current Channel from version 2405
Excel for the web
Yes
Preview
Mac
Current Channel from version 16.96
Preview through the Microsoft 365 Insider programme (Beta Channel)
iPad, iPhone, Android
No: the workbook displays, but the Python cells show an error when recalculated
No
Create a first Python cell that reads the Ventes table
Add an Analyse sheet and click in cell A1. The labels may vary depending on your version of Excel and your plan: look for the locations described.
Formulas tab, Insert Python button. The cell shows the PY icon.
Type ventes = then select the Sales (Ventes) table with the mouse: Excel writes xl("Ventes[#All]", headers=True).
Confirm with Ctrl+Enter. Enter on its own adds a line of code.
The cell shows a card icon: it is a Python object, a DataFrame. Click the icon to see a preview of the 20 rows.
To see the values in the grid, open the Python output menu to the left of the formula bar and choose Excel Value (shortcut Ctrl+Alt+Shift+M).
Have Copilot write the code
Since April 2026, Copilot can use Python when it edits the workbook: you ask for it in your prompt, or it decides on its own when the analysis suits it, to transform data or produce a chart. Your job changes: you no longer write the code, you read it. So insist on comments in French, one line per step, and the names of the columns used.
The October sales analysis, in Edit mode
Analyse October sales in the Ventes table with Python, by week and by customer, with a chart. Code commented in French.
Details: ISO week (Monday to Sunday) taken from the Date column; amount excl. VAT with customers in rows and weeks in columns, 0 where there is nothing; a Total row and column. Put the Python cell in A1 of a new Analyse sheet, with the chart of weekly totals below it. Tell me which weeks are incomplete within the month.
Roughly what you should get
What the answer should look like: an Analyse sheet with a PY cell that returns a table of 7 customers over weeks 40 to 44, total 8,071.00; a column chart of the five weeks; in the pane, the comment that week 40 only covers 1 and 2 October and week 44 stops on 30 October.
The expected code in the PY cell in A1, with commentsPython
import pandas as pd
# Le tableau Ventes en entier, ligne d'en-tête comprise
ventes = xl("Ventes[#All]", headers=True)
# Numéro de semaine ISO (du lundi au dimanche) tiré de la colonne Date
ventes["Semaine"] = pd.to_datetime(ventes["Date"]).dt.isocalendar().week
# Montant HT par client (en lignes) et par semaine (en colonnes), 0 si rien
par_semaine = ventes.pivot_table(index="Client", columns="Semaine",
values="Montant HT", aggfunc="sum", fill_value=0)
# Totaux de ligne et de colonne, pour le recalcul témoin (8 071,00)
par_semaine["Total"] = par_semaine.sum(axis=1)
par_semaine.loc["Total"] = par_semaine.sum()
par_semaine
The last line, par_semaine on its own, is what the cell returns. Code run on 19/11/2026 on the twenty sales in the running example: it gives the table below.
The result, amounts excl. VAT in euros (ISO weeks of October 2026)
Client
S40
S41
S42
S43
S44
Total
C-101
288,00
90,00
204,00
0
0
582,00
C-108
460,00
420,00
0
476,00
0
1 356,00
C-112
0
408,00
356,00
360,00
0
1 124,00
C-115
0
264,00
287,50
0
267,00
818,50
C-120
0
612,00
0
360,00
654,00
1 626,00
C-123
0
0
585,00
292,50
0
877,50
C-130
0
0
872,00
290,00
525,00
1 687,00
Total
748,00
1 794,00
2 304,50
1 778,50
1 446,00
8 071,00
From prompt to checked result
1Request
“With Python”, the question, the columns, code commented in French.
2PY cell
Copilot writes the code in a cell; the PY icon marks it.
3Result
A table or chart, as a Python object or as Excel values.
4Reading the code
Every line understood: which table, which filter, which date.
5Check calculation
The total checked against SUM(Ventes[Montant HT]): 8,071.00.
Read the code before the result: it tells you which rows were used.
Read the code line by line before looking at the figures. [#All] ensures every row of the table is read, including those added tomorrow. isocalendar().week numbers weeks from Monday to Sunday: week 40 runs from 28 September to 4 October, so it contains only two days of October, hence its €748.00 (288.00 + 460.00). It isn’t a bad week; it’s a partial week. Then do the control recalculation: =SUM(Ventes[Montant HT]) in a neighbouring cell should give 8,071.00, like the Total cell in the Python table, and the Total column should match the per-client amounts in the running example (C-130 1,687.00, C-120 1,626.00…).
The chart, in a second PY cell below the firstPython
import matplotlib.pyplot as plt
# Total HT par semaine, repris de la cellule précédente (ligne Total, sans la colonne Total)
semaines = par_semaine.loc["Total"].drop("Total")
fig, ax = plt.subplots(figsize=(7, 4))
semaines.plot(kind="bar", ax=ax)
ax.set_title("Octobre 2026, la semaine 42 porte 2 304,50 € HT")
ax.set_xlabel("Semaine ISO")
ax.set_ylabel("Montant HT (€)")
fig
The second cell reuses par_semaine because it is calculated after the first: Excel calculates Python cells row by row, from top to bottom. The title states the message, as in lesson 7.
Do hotels pay later than restaurants?
Matching Relances and Ventes, in a PY cellPython
import pandas as pd
relances = xl("Relances[#All]", headers=True)
ventes = xl("Ventes[#All]", headers=True)
date_ref = pd.Timestamp("2026-11-16") # la date de référence de K1, écrite en dur
# Le type de chaque client, lu dans Ventes (un code client = un type)
type_client = dict(zip(ventes["Client"], ventes["Type de client"]))
relances["Type de client"] = relances["Client"].map(type_client)
# Factures échues et non soldées seulement, avec leur retard en jours
echues = relances[(relances["Reste dû"] > 0) & (pd.to_datetime(relances["Échéance"]) < date_ref)].copy()
echues["Retard (jours)"] = (date_ref - pd.to_datetime(echues["Échéance"])).dt.days
# Par type de client : nombre de factures, reste dû, retard moyen
synthese = echues.groupby("Type de client").agg(
Factures=("Facture", "count"),
Reste_du=("Reste dû", "sum"),
Retard_moyen=("Retard (jours)", "mean"),
).sort_values("Retard_moyen", ascending=False)
synthese
Result of the run on 19 November 2026: Campsite 3 invoices, €2,894.40, 33.3 days; Restaurant 2 invoices, €1,224.00, 22.0 days; Hotel 2 invoices, €2,062.40, 20.5 days; Brasserie 1 invoice, €345.60, 16 days; Caterer 1 invoice, €316.80, 10 days. F26-1054, not yet due, is excluded.
Restaurants pay on average 22 days late, hotels 20.5 days. This tells you nothing: two invoices on each side, and the hotel average mixes F26-0995 (39 days) and F26-1051 (2 days). The figure is correct; the conclusion would be wrong. Campsite C-120, on the other hand, stands out for a clear reason: F26-0942, 66 days, the only invoice over 60 days. Our view: a Python analysis of fourteen invoices should be presented as a lead to follow up on six months of data, never as a finding. The honest answer to Mathieu fits in one sentence: “One month isn’t enough to tell; I’ll rerun the analysis in May on six months.”
Formula, PivotTable, Python or Analyst?
1Does the question go beyond a sum, a count or an average by category?
No A formula or PivotTable, as in lessons 4 and 7.
2Does it need a calculation formulas handle poorly: matching two tables, statistics, a chart built by code?
No Ask Copilot in Edit mode: it chooses formulas and charts itself.
3Does the data fit in a single open workbook?
No The Analyst agent, in the Microsoft Copilot app, with a licence.
Yes to allPython in Excel: a PY cell, commented and reviewed code, a result that recalculates in the workbook.
Stop at the first “no”: the simplest tool that answers the question is the right one.
The Analyst agent, when the data goes beyond the workbook
The Analyst agent is a Microsoft agent specialising in data analysis and charting. It does not live in Excel: you find it in the Microsoft Copilot app, on microsoft365.com, in the Agents section of the left-hand pane, or through Copilot Chat. It requires a licence: Microsoft 365 Copilot or Copilot Business for organisations, Microsoft 365 Premium or Personal for individuals. Without a licence, or if the administrator hasn’t enabled it, it doesn’t appear or returns an error. According to Microsoft’s March 2025 announcement, it runs Python and shows the code it uses, so you can read it as you would in Excel.
A request to the Analyst that cross-references Sales and Reminders
You are helping the head of an 18-employee distributor of supplies for cafés, hotels and restaurants.
Data: the workbook [workbook name] contains the Sales table (October 2026 sales, amounts excl. VAT) and the Reminders table (invoices and amounts outstanding incl. VAT at 16 November 2026, reference date in K1).
Question: which customers weigh most in October sales and in the overdue amount outstanding at 16 November 2026? Rank the seven customers on these two criteria.
Rules: an invoice is overdue if its due date is before 16 November 2026; do not count invoices paid in full. Show the code you run, give the total sales and the total overdue amount so I can compare them with my figures, and say what the sample does not allow us to conclude.
Roughly what you should get
What the answer should look like: a table of seven customers, sales excl. VAT and overdue balance; C-120 top for overdue balance (€2,894.40 across three invoices, one of them 66 days overdue) and second for sales (€1,626.00); C-130 first for sales (€1,687.00) with €1,046.40 overdue for 2 days; totals €8,071.00 excl. VAT and €6,843.20 incl. VAT; a caveat about having only one month of data.
Provide only the columns you need: customer codes, amounts, dates. There is no reason to include a customer name or a contact.What calls for Python or the Analyst
HighValue of the answerLow
Formula or PivotTable
The answer is clear and the setup is quick: stay in Excel.
Python or Analyst
A question that comes back every month, tables to reconcile.
A question in Chat mode
A one-off question, with nothing to build.
Don't
A statistical model on fourteen invoices.
LowSet-up effortHigh
The highlighted box is where to start; the bottom-right box is not done.
Mistakes to avoid
Trusting the result of a Python cell without reading the code, “because it’s just calculation”.
The calculation is correct for the data it received. A fixed range, one filter too many or today’s date instead of the reference date give a wrong result with no error shown.
Read each line: which table, which range, which filter, which date. Then redo a total with a formula in a neighbouring cell.
Writing a range such as xl("A1:J21") instead of the table reference.
The range misses rows added the following month. The analysis updates, but on incomplete data.
Use xl("Ventes[#All]", headers=True), or select the table with the mouse while editing the PY cell so that Excel writes the reference.
Presenting an average calculated on a few rows as a conclusion.
Python gives decimals, which looks serious. With two invoices per group, a single late payment changes the whole ranking.
Always give the number of rows in each group, and say when the sample is too small to draw a conclusion.
Looking for the Analyst agent in Excel, or promising it to the whole team without licences.
The Analyst lives in the Microsoft Copilot app and requires a Microsoft Copilot licence; without one, or without activation by the administrator, it doesn’t appear.
Check the licence in your account settings, look for the Analyst on microsoft365.com under Agents, and keep Python in Excel for accounts without a Copilot licence.
3 SME situations followed from start to finish: the prompts exactly as they were written, the model answer to aim for, and what was checked before sending.
Example 1
A distributor’s sales by sales rep and by week
Sandrine is head of sales administration and accounts at an 18-employee distributor of supplies for cafés, hotels and restaurants in Mérignac. Mathieu wants to see Lucie’s and Paul’s sales week by week at the committee meeting every Monday. The weekly PivotTable forces her to group the dates by hand every month.
Monday’s committee meeting
8 h 30Month’s export pasted in
The Ventes table grows, and [#All] keeps up.
8 h 35Recalculation
The PY cells recalculate, total checked.
8 h 45Reading
Split weeks, orders that tip the balance.
9 hCommittee
One chart, one sentence per salesperson.
Request 1
Edit mode. Using Python, calculate the amount excl. VAT in the Ventes table by sales rep and by ISO week, with sales reps in rows and weeks in columns, plus a clustered column chart. Code commented in French, in a new sheet called Comité. Flag any partial weeks.
Model answer
Comité sheet created. Table: Lucie W40 288.00, W41 498.00, W42 2,017.00, W43 942.50, W44 525.00, total 4,270.50; Paul W40 460.00, W41 1,296.00, W42 287.50, W43 836.00, W44 921.00, total 3,800.50. Total 8,071.00. Incomplete weeks: W40 (1 and 2 October), W44 (26 to 30 October; the 31st is a Saturday with no sales).
Sandrine reads the code: xl("Ventes[#All]", headers=True), isocalendar().week, pivot_table on Commercial. She checks the totals against those of the running example, 4,270.50 and 3,800.50: identical.
Request 2
Explain why Lucie makes 2,017.00 in week 42 and Paul only 287.50, based on the rows of the Ventes table.
Model answer
Week 42 (12 to 18 October): Lucie invoiced F26-1048 (585.00), F26-1049 (356.00), F26-1051 (872.00) and F26-1052 (204.00), a total of 2,017.00; Paul invoiced only F26-1050 (287.50). C-130’s large linen order (872.00) alone accounts for 43% of Lucie’s week.
She finds the five invoices in the table. The message for the committee: Lucie’s week 42 comes down to one hotel order, not a trend.
What was checked before sending
The Python cell’s total checked against SUM(Ventes[Montant HT]): 8,071.00.
Totals per sales rep checked against those of the running example (4,270.50 and 3,800.50).
Partial weeks flagged on the chart, so no one reads a drop in W40.
Order of magnitude: the committee sheet updates itself every month instead of twenty minutes of grouping dates, and reading the code took ten minutes the first time.
Example 2
Hours for one week of maintenance, read alongside the schedule
Julie is a scheduling assistant at a 35-employee heating, air-conditioning and refrigeration maintenance company in Bègles. Thomas, the management controller, asks her for the variance between planned and actual hours per technician for week 46, with a chart, for the Friday meeting.
What the chart says, what the schedule says
Reading the chart alone
Sofia: −58.3% of hours worked
Inès: +27.8%, the slowest
An alert on two technicians
Business sense check
Sofia: 4 hrs postponed, caretaker absent
Inès: two longer refrigeration call-outs
No alerts about individuals
Request 1
Edit mode. Using Python, calculate for each technician in the Planning table the total planned hours, the total hours worked, and the variance in hours and as a percentage of planned hours, with a column chart of the percentage variances. Code commented in French. Give the totals.
Model answer
Inès 9 planned, 11.5 done, +2.5 h (+27.8%); Marc 19, 20, +1 h (+5.3%); Sofia 6, 2.5, −3.5 h (−58.3%); Yanis 18, 19.5, +1.5 h (+8.3%). Totals: 52 h planned, 53.5 h done, +1.5 h.
Julie finds the running example’s check figures (52 and 53.5 h). She notices the code also calculates a “total percentage variance” of −16.9% by adding up the percentages: a meaningless sum. She has it removed.
Request 2
Remove the percentage total row. Add an Interventions reportées column that counts the rows with the status Reporté for each technician.
Model answer
Column added: Sofia 1 (Syndic, Talence, communal boiler servicing, 4 h planned, 0 done), the others 0. Overall variance: +1.5 h out of 52, i.e. +2.9%.
The chart alone would have pointed at Sofia. The schedule tells a different story: 4 hours postponed because the caretaker was absent. Julie adds this note below the chart.
What was checked before sending
Python cell totals compared with the running example: 52 hrs planned, 53.5 hrs worked.
The overall percentage recalculated with a formula: 1.5 / 52 = 2.9%, not the sum of the percentages.
Every large variance checked in the schedule before the meeting: Sofia’s postponement, Inès’s refrigeration call-outs.
Order of magnitude: a quarter of an hour for the table and chart instead of forty minutes, and a technician spared unfair blame.
Example 3
What the Analyst agent offers a business leader
Mathieu runs the distributor in Mérignac, 18 employees, on Microsoft 365 Business with a Copilot Business licence for himself and for Sandrine. Before renegotiating payment terms with his largest clients, he wants to cross-reference October sales with the balance outstanding at 16 November 2026, without waiting for Sandrine to have time.
From question to meeting
1Question
Who buys the most, who owes the most?
2Analyst
Two PivotTables, code shown.
3Totals compared
8,071.00 and 6,843.20, in Sandrine’s workbook.
4Meeting note
Three lines, figures copied as they are.
Request 1
In the Microsoft Copilot app, Agents section, Analyst: “Using the Ventes and Relances tables in the [workbook name] workbook, rank the seven customers by October sales excl. VAT and by overdue amount outstanding as at 16/11/2026, excluding settled invoices. Show the code run and the totals.”
Mathieu asks Sandrine to check both totals against her figures: 8,071.00, and 7,194.20 minus 351.00 for F26-1054, not yet due, giving 6,843.20. They match.
Request 2
Write three lines to prepare my meeting with client C-120, using only these figures.
Model answer
“C-120 is our second-largest customer for October (€1,626.00 excl. VAT) and the one that owes us the most overdue money: €2,894.40 incl. VAT across three invoices. The oldest, F26-0942, is 66 days overdue. Aim of the meeting: payment of F26-0942 before the end of November and a payment schedule for the other two.”
Mathieu keeps the note. The decision on payment terms remains his: Microsoft warns against making any financial decision based on Copilot alone.
What was checked before sending
Analyst’s two totals checked against Sandrine’s figures: €8,071.00 excl. VAT and €6,843.20 incl. VAT.
The code shown by Analyst, checked for the “overdue” rule: due date before 16 November 2026.
The meeting note checked against the lines of invoice F26-0942 before being taken along.
Order of magnitude: a quarter of an hour for Mathieu instead of an hour of Sandrine’s time, with figures checked in five minutes.
Bertrand, manager of the delicatessen in Libourne (9 employees), wants to know which product family earns the most per order and which customers come back. Élodie has the export cleaned in lesson 9, the Boutique table, with a Famille column (RIL, CON, FOI, CAN) pulled in by formula in lesson 11. The eleven orders, amounts incl. VAT: 1001 CL-2041 RIL 15.80; 1002 CL-2056 CON 17.40; 1003 CL-2061 FOI 24.90; 1004 CL-2041 CAN 19.00; 1005 CL-2073 RIL 31.60; 1006 CL-2080 FOI 49.80; 1007 CL-2056 CON 5.80; 1008 CL-2092 CAN 9.50; 1009 CL-2097 FOI 74.70; 1010 CL-2101 RIL 7.90; 1011 CL-2061 CAN 28.50. Write the prompt for Copilot, write the expected Python code, give the check figures and say what Bertrand can conclude.
Choose the tool with the decision diagram: would a formula or a PivotTable do?
Write the prompt in Edit mode, with Python, the columns, the expected result and comments in French.
Write or check the code: total amount, number of orders and average basket by family; number of orders per customer.
Prepare three control recalculations to do by formula.
Write the sentence for Bertrand, with its limits.
See the answers
Honestly, a PivotTable would do here: sum and average by family, count by customer. Python is justified if Élodie wants to rerun the analysis every month on 200 orders with the same chart, or add a calculation later that a PivotTable can’t do. The exercise is for learning to read code on a case you can recalculate in your head.
The request
Using Python, analyse the Boutique table: for each value in the Famille column, the total amount incl. VAT, the number of orders and the average basket, sorted from largest to smallest amount; then the number of orders and total amount per customer, sorted the same way. Code commented in French, two PY cells in a new Analyse sheet. Give the grand total so I can check it against 284.90.
Roughly what you should get
What the answer should look like: two tables. By family: FOI €149.40 across 3 orders (average basket 49.80), CAN 57.00 across 3 (19.00), RIL 55.30 across 3 (18.43), CON 23.20 across 2 (11.60). By customer: eight customers, three with two orders (CL-2061 53.40; CL-2041 34.80; CL-2056 23.20). Total 284.90.
The code in the first PY cellPython
import pandas as pd
# L'export nettoyé, ligne d'en-tête comprise
boutique = xl("Boutique[#All]", headers=True)
# Par famille : total, nombre de commandes, panier moyen, du plus gros au plus petit
par_famille = boutique.groupby("Famille")["Montant"].agg(
Total="sum", Commandes="count", Panier_moyen="mean"
).sort_values("Total", ascending=False)
par_famille
The second cell does the same with groupby("Client"). If the Montant column is still stored as text, the code fails or concatenates: the clean-up from lesson 9 comes before any analysis.
The sentence for Bertrand: “In November, foie gras makes up more than half of online sales (€149.40 out of €284.90) with a basket of €49.80; three customers out of eight ordered twice. Eleven orders aren’t enough to decide on a promotion: I’ll rerun the analysis at the end of December, with the festive season.”
Practise
Three more exercises, from the most guided to the most demanding. The material is provided in full: copy it into your tool, then check your work against the criteria before opening the answers.
Level 1 · guided10 min
Read Python code before trusting its result
Copilot wrote the code below for Karim, buyer at the Mérignac distributor, who wanted the stock value by family. Read it and answer: which table is read, are all the rows read, what does each line calculate, and what total should Karim get with a formula?
The material to work on
import pandas as pd
# Le tableau Stock
stock = xl("A1:H10", headers=True)
# Valeur de chaque ligne : stock × prix d'achat HT
stock["Valeur"] = stock["Stock"] * stock["Prix d'achat HT"]
# Valeur par famille, de la plus forte à la plus faible
stock.groupby("Famille")["Valeur"].sum().sort_values(ascending=False)
Reminder: the Stock table has 12 items (rows 2 to 13 of the sheet), total value €1,977.60 excl. VAT.
Check your work
The range A1:H10 is identified as fixed and incomplete: it stops at row 10
The three missing references are named (EM-006, PM-003, PM-009)
The correction uses xl("Stock[#All]", headers=True)
The control recalculation is =SUMPRODUCT(Stock[Stock],Stock[Prix d'achat HT]), giving 1,977.60
See the answers
The range A1:H10 reads the header and only nine items: EM-006, PM-003 and PM-009 (rows 11 to 13) are missing. The Python total would be 1,977.60 − 70.00 − 114.00 − 72.00 = €1,721.60 excl. VAT, wrong with no visible error. The fix is a single table reference.
The corrected line and the control recalculationPython
# Tout le tableau Stock, y compris les références ajoutées plus tard
stock = xl("Stock[#All]", headers=True)
# Recalcul témoin à écrire dans une cellule Excel voisine (pas en Python) :
# =SOMMEPROD(Stock[Stock];Stock[Prix d'achat HT]) -> 1 977,60
Level 2 · independent20 min
Prepare the Python prompt for Monday’s payment reminders
Every Monday, Sandrine wants a table of the balance outstanding by overdue band and by client type, with a stacked chart, based on the Relances and Ventes tables. Write the prompt to Copilot in Edit mode, the list of checks to run on the code, and the figures the cell must match at 16 November 2026.
The material to work on
Reminders table at 16 November 2026: 14 invoices, total outstanding €7,194.20 incl. VAT; reference date in K1.
Expected bands (running example): Over 60 days 864.00 (F26-0942); 31 to 60 days 1,750.40 (F26-0995, F26-1003); 1 to 30 days 4,228.80 (six invoices); Not yet due 351.00 (F26-1054); four invoices paid in full.
Customer types (Customer type column of the Sales table): C-101 Brasserie, C-108 Hotel, C-112 Restaurant, C-115 Caterer, C-120 Campsite, C-123 Staff restaurant, C-130 Hotel.
Check your work
The prompt names both tables, the reference date and the band boundaries
It excludes settled invoices and keeps the Non échue band
The code is checked for the date (no TODAY, and no current date in Python)
The four band totals and the total of 7,194.20 must match
The prompt requires comments in French and the grand total
See the answers
The request
Using Python, build the amount outstanding by ageing band and by customer type. Data: the Relances table (reference date 16/11/2026, the one in K1: write it in the code, do not use today’s date) and the Type de client column of the Ventes table for each customer’s type. Bands based on days overdue = reference date − Échéance: Non échue (0 or less), 1 à 30 j, 31 à 60 j, Plus de 60 j. Exclude invoices where Reste dû is zero. Types in rows, bands in columns, row and column totals, then a stacked column chart. Code commented in French, in a Lundi sheet.
Roughly what you should get
What the answer should look like: a table of six types across four bands, column totals 351.00; 4,228.80; 1,750.40; 864.00; grand total 7,194.20; a stacked chart in which the campsite accounts for the only share over 60 days.
The date in the code is 2026-11-16, hard-coded, not today’s date.
The bands: delay <= 0 Not overdue, <= 30, <= 60, beyond that Over 60 days, as in the Tranche column from lesson 4.
The filter Reste dû > 0 removes the four paid invoices.
The column totals match those of the running example, with a grand total of 7,194.20.
Level 3 · demanding case30 min
Choose the tool for four management questions
Mathieu sends you four questions. For each one, choose the tool (formula, PivotTable, Copilot in Edit mode, Python in Excel, Analyst agent, or nothing), justify your choice with the decision diagram and the effort × value matrix, write the prompt or formula, and state which check you will do. The company has Microsoft 365 Business Standard for everyone and two Copilot Business licences (Mathieu, Sandrine).
The material to work on
E-mail from Mathieu, Monday 16/11/2026:
“1. What is the amount sold excl. VAT by family in October?
2. Do Lucie’s sales show a week-on-week trend? I want a clean chart for the committee.
3. Can you cross-reference October sales, the payment reminders and the delivery rounds file, which is in another SharePoint workbook, to see whether customers delivered at the end of a round pay later?
4. Give me a 2027 sales forecast by customer based on October.”
Check your work
Question 1 calls for a PivotTable or SUMIFS, with the 8,071.00 check
Question 2 calls for Python or a chart requested from Copilot, with the caveat about cut-off weeks
Question 3 calls for the Analyst agent (Mathieu’s or Sandrine’s licence), with a caveat about the sample
Question 4 is declined or reworded: one month of data doesn’t make an annual forecast
Every answer comes with a numerical check
See the answers
The four decisions
Question
Tool
Inspection
1. Sales by family
PivotTable requested from Copilot (lesson 7)
Total 8,071.00; Linen 2,273.50, Tableware 2,178.00, Hygiene 1,992.50, Small equipment 913.00, Packaging 714.00
2. Lucie’s trend
Python in Excel, chart by ISO week
Total 4,270.50; W40 and W44 flagged as incomplete; no trend claimed over five weeks
3. End of round and delays
Analyst agent, data from three sources
Totals of each table re-checked; caveat on fourteen invoices
4. 2027 forecast
Nothing for now
One month of sales does not make a season: revisit with twelve months of history
Using the Ventes and Relances tables in the [workbook name] workbook and the Tournees table in the [delivery rounds workbook name] workbook, tell me whether customers delivered at the end of a round are later in paying as at 16/11/2026. Define “end of round” as the last two stops. Show the code and the number of invoices in each group, and say whether the sample is large enough to draw a conclusion.
Roughly what you should get
What the answer should look like: two groups of a few invoices, a difference in average delay, and the expected caveat: fewer than fifteen invoices, so no conclusion is possible.
The answer to question 4 is the most useful of the four: saying no to a forecast that no tool can base on one month. Suggest to Mathieu that you revisit the question in January with the full 2026 history.
The course terms defined simply, in alphabetical order, from Copilot’s modes to structured references, with a work example and the lesson that covers it.
Every prompt for Copilot in the course, including answers, practical examples and practice exercises, arranged by module and lesson, with filters to find the right one.
For each lesson, the main exercise and the three graded practice exercises with their tables reproduced in full, to redo in your own Excel; all the answers, formulas included, are grouped at the end.
The course’s practical examples, job by job: the situation, the prompt as it was written, the typical response and what was checked before sending the result.
All the lessons in a single PDF: objectives, written lesson with its diagrams, tables, formulas and prompts, common mistakes, exercise and key points to remember. The practice exercises and answers are in the workbook, the examples in the collection.
Your notes stay on this device; they are not sent anywhere.
A question for the tutor
A result that doesn’t match the model answer, a prompt that gets you nowhere, a case specific to your business: write to us with your prompt and the response you got. A Bonbay Académie trainer replies within 24 working hours, on your case.