Excel 365 Question
Discussion
I'm updating my Excel skills to accommodate new features added in 365. Power Query in particular.
I think I know the answer to this ("No"), but I'm going to ask anyway.
I have a table, and as new rows are added , I need to manually update one field. Let's say there's a column called "Serial number", and one called "Comment", and I manually add a comment (or not) against each serial number.
As the table updates and more rows are added, can I get Excel to auto-populate new "Comment" cells if the serial number (and my manual comment) have appeared in the table previously?
I know I could use another table of serial numbers and comments, and get Excel to pick from that, but I'm wondering if there's some AI logic or somesuch that will just say "This serial number's been entered before, and the comment against it was "X", so I'll put the same comment against it this time too.
Can I do it during the Transfom Data stage of PQ?
I think I know the answer to this ("No"), but I'm going to ask anyway.
I have a table, and as new rows are added , I need to manually update one field. Let's say there's a column called "Serial number", and one called "Comment", and I manually add a comment (or not) against each serial number.
As the table updates and more rows are added, can I get Excel to auto-populate new "Comment" cells if the serial number (and my manual comment) have appeared in the table previously?
I know I could use another table of serial numbers and comments, and get Excel to pick from that, but I'm wondering if there's some AI logic or somesuch that will just say "This serial number's been entered before, and the comment against it was "X", so I'll put the same comment against it this time too.
Can I do it during the Transfom Data stage of PQ?
Sporky said:
Could that be done with an XLookup?
Only if I create a separate list of numbers and comments and, whilst I can do that, I'm hoping there's a slicker way.The issue with a lookup is that if the serial number is unique, there will be no comment added automatically but I might add one manually, and that will overwrite the lookup formula.
Doofus said:
The issue with a lookup is that if the serial number is unique, there will be no comment added automatically but I might add one manually, and that will overwrite the lookup formula.
I might have misunderstood, but that'd be the first entry for that serial number, so OK to overwrite the formula. If the serial number appears later it'd pick up that earlier entry.You want the lookup to look at the cells from the top to the tow above it, so something like $A$2:$A9 (in the 10th row, assuming serial numbers are in A) as the range to search, and the same but substituting the comment column letter as the range to return.
Unless you might put the serial number into a higher row.
Sporky said:
I might have misunderstood, but that'd be the first entry for that serial number, so OK to overwrite the formula. If the serial number appears later it'd pick up that earlier entry.
I know, but having a column with some text and some formulas feels like a messy compromise. 
Sporky said:
You want the lookup to look at the cells from the top to the tow above it, so something like $A$2:$A9 (in the 10th row, assuming serial numbers are in A) as the range to search, and the same but substituting the comment column letter as the range to return.
Unless you might put the serial number into a higher row.
Again, yes, but this is a table so I'm not using cell references.Unless you might put the serial number into a higher row.
CHatGPT is made for this sort of question - excel stuff is really where it excels. Just be careful what info you put in - I'm allowed to put generic stuff in to help get answers, but sensitive info for instance.
Answer to your question above
Short answer: you can absolutely auto-populate—but not by “remembering” inside Power Query. PQ is stateless: it won’t recall what you typed last refresh. You need a keyed source of truth for comments (even if it lives in the same workbook), then merge it in. Here are practical ways to do it:
* `Serial number`
* `Comment`
* (Optional but useful) `CommentDate` or `Version` if comments can change.
2. In **Power Query**:
* Load your incoming table (call it `Fact`).
* Load the `Comments` table as a separate query.
* (Optional) If there can be multiple comments per serial, “**Group By**” the `Comments` table on `Serial number` and keep the **latest** comment (use `Max` on `CommentDate`, then merge back to get that row).
* **Merge** `Fact` → `CommentsLatest` on `Serial number` with a **Left Outer** join.
* **Expand** to bring in `Comment`.
That’s it. Every refresh, any new serial number that already exists in `Comments` gets its comment pulled in automatically.
let
Source = Excel.CurrentWorkbook(){[Name="Fact"]}[Content],
Fact = Table.TransformColumnTypes(Source,{{"Serial number", type text}}),
CommentsSrc = Excel.CurrentWorkbook(){[Name="Comments"]}[Content],
Comments = Table.TransformColumnTypes(CommentsSrc,{
{"Serial number", type text}, {"Comment", type text}, {"CommentDate", type datetime}
}),
// keep the latest comment per serial (drop this section if you only ever have one row per serial)
Grouped = Table.Group(Comments, {"Serial number"},
{{"Latest", each Table.Max(_, "CommentDate"), type table [Serial number=nullable text, Comment=nullable text, CommentDate=nullable datetime]}}),
CommentsLatest = Table.ExpandTableColumn(Grouped, "Latest", {"Comment"}, {"Comment"}),
Merged = Table.NestedJoin(Fact, {"Serial number"}, CommentsLatest, {"Serial number"}, "C", JoinKind.LeftOuter),
Expanded = Table.ExpandTableColumn(Merged, "C", {"Comment"}, {"Comment"})
in
Expanded
```
> Where do you put new comments you type by hand?
>
> Do **not** type them into the PQ output table (they’ll be wiped on refresh). Instead, type or paste new/updated comments into the `Comments` table (your source of truth). PQ will then merge them in every time.
WithKey = Table.TransformColumns(Fact, {{"Serial number", each Text.Upper(Text.Trim(_)), type text}});
```
Do the same on the `Comments` query.
---
Assume your table is `Tbl` with columns `Serial number` and `Comment`. Put this **in the Comment column** (as a calculated column):
```excel
=IF(
[@Comment]<>"",
[@Comment],
IFERROR(
LOOKUP(
2, 1/((Tbl[Serial number]=[@[Serial number]])*(ROW(Tbl[Serial number])<ROW())),
Tbl[Comment]
),
""
)
)
```
2. Write the comment into the output table.
Answer to your question above
Short answer: you can absolutely auto-populate—but not by “remembering” inside Power Query. PQ is stateless: it won’t recall what you typed last refresh. You need a keyed source of truth for comments (even if it lives in the same workbook), then merge it in. Here are practical ways to do it:
- What works (and what doesn’t)
- **Power Query cannot “learn” or keep memory** of past outputs. No built-in AI matching there.
- **Best-practice:** keep a tiny **Comments** table (SerialNumber → Comment). Merge it onto your incoming data in PQ.
- If you really don’t want a separate table, you can do a **formula-only approach** that looks “upwards” in the same table to reuse a previous comment for the same serial number.
- Option A (recommended): Merge a Comments table in Power Query
* `Serial number`
* `Comment`
* (Optional but useful) `CommentDate` or `Version` if comments can change.
2. In **Power Query**:
* Load your incoming table (call it `Fact`).
* Load the `Comments` table as a separate query.
* (Optional) If there can be multiple comments per serial, “**Group By**” the `Comments` table on `Serial number` and keep the **latest** comment (use `Max` on `CommentDate`, then merge back to get that row).
* **Merge** `Fact` → `CommentsLatest` on `Serial number` with a **Left Outer** join.
* **Expand** to bring in `Comment`.
That’s it. Every refresh, any new serial number that already exists in `Comments` gets its comment pulled in automatically.
- # M snippet (illustrative)
let
Source = Excel.CurrentWorkbook(){[Name="Fact"]}[Content],
Fact = Table.TransformColumnTypes(Source,{{"Serial number", type text}}),
CommentsSrc = Excel.CurrentWorkbook(){[Name="Comments"]}[Content],
Comments = Table.TransformColumnTypes(CommentsSrc,{
{"Serial number", type text}, {"Comment", type text}, {"CommentDate", type datetime}
}),
// keep the latest comment per serial (drop this section if you only ever have one row per serial)
Grouped = Table.Group(Comments, {"Serial number"},
{{"Latest", each Table.Max(_, "CommentDate"), type table [Serial number=nullable text, Comment=nullable text, CommentDate=nullable datetime]}}),
CommentsLatest = Table.ExpandTableColumn(Grouped, "Latest", {"Comment"}, {"Comment"}),
Merged = Table.NestedJoin(Fact, {"Serial number"}, CommentsLatest, {"Serial number"}, "C", JoinKind.LeftOuter),
Expanded = Table.ExpandTableColumn(Merged, "C", {"Comment"}, {"Comment"})
in
Expanded
```
> Where do you put new comments you type by hand?
>
> Do **not** type them into the PQ output table (they’ll be wiped on refresh). Instead, type or paste new/updated comments into the `Comments` table (your source of truth). PQ will then merge them in every time.
- Tip:** Normalize the join key—trim, set to upper/lower, remove spaces—to avoid mismatches:
WithKey = Table.TransformColumns(Fact, {{"Serial number", each Text.Upper(Text.Trim(_)), type text}});
```
Do the same on the `Comments` query.
---
- Option B: Formula-only auto-fill inside the sheet
Assume your table is `Tbl` with columns `Serial number` and `Comment`. Put this **in the Comment column** (as a calculated column):
```excel
=IF(
[@Comment]<>"",
[@Comment],
IFERROR(
LOOKUP(
2, 1/((Tbl[Serial number]=[@[Serial number]])*(ROW(Tbl[Serial number])<ROW())),
Tbl[Comment]
),
""
)
)
```
- If you type a comment, it stays.
- If you leave it blank, it grabs the **last** earlier comment for that serial (if any).
- Caveat: formulas referencing the same column can be finicky; structured refs + `ROW()` work fine for many, but test on your dataset. Also, this won’t help if your “previous” comment is only present in a refreshed PQ output (because refresh overwrites the column). It’s best when your table is manual or the column is formula-driven.
- Option C: Office Scripts / Power Automate (advanced)
- You can keep comments in a separate sheet and use a **flow** to:
2. Write the comment into the output table.
- This gives you more control (e.g., prompts if multiple past comments exist), but it’s more setup than a simple PQ merge.
- Bottom line
- **During Transform Data (PQ)**: Yes—**via a Merge** with a comments table. PQ won’t auto-infer or remember prior rows by itself.
- **If you want zero extra tables**: use the **formula approach** that copies a previous comment for the same serial on insert—but avoid mixing it with PQ overwriting that column on refresh.
Thank you. That involves keeping a(nother) table, containing serials and comments, which is what I was hoping to avoid.
I have concluded that, without a but of VBA, it's not possible. I'm trying to create something robust that several people can use, but this is one element that I can't open up to them all.
Thanks all.
I have concluded that, without a but of VBA, it's not possible. I'm trying to create something robust that several people can use, but this is one element that I can't open up to them all.
Thanks all.
Doofus said:
Thank you. That involves keeping a(nother) table, containing serials and comments, which is what I was hoping to avoid.
I have concluded that, without a but of VBA, it's not possible. I'm trying to create something robust that several people can use, but this is one element that I can't open up to them all.
Thanks all.
Did you not read Option B above?I have concluded that, without a but of VBA, it's not possible. I'm trying to create something robust that several people can use, but this is one element that I can't open up to them all.
Thanks all.
surveyor said:
Doofus said:
Thank you. That involves keeping a(nother) table, containing serials and comments, which is what I was hoping to avoid.
I have concluded that, without a but of VBA, it's not possible. I'm trying to create something robust that several people can use, but this is one element that I can't open up to them all.
Thanks all.
Did you not read Option B above?I have concluded that, without a but of VBA, it's not possible. I'm trying to create something robust that several people can use, but this is one element that I can't open up to them all.
Thanks all.
My question was "As the table updates and more rows are added, can I get Excel to auto-populate new "Comment" cells if the serial number (and my manual comment) have appeared in the table previously?", and the answer is "No".
This is not a problem I can't solve. I wanted to know of there was a slicker way of doing it.
Gassing Station | Computers, Gadgets & Stuff | Top of Page | What's New | My Stuff