Improve the
purchase notification.
Use expressions to clean text, format a timestamp, calculate a fee, and handle an empty business reason.
Guided practice · Text, dates, numbers & empty valuesRead a value. Transform a value.
Dynamic content gives you a value from an earlier step. An expression can transform that value or calculate a new one. Use fx to enter the expression into a field.
Select Copy expression. Click the destination field in the email action, place the cursor where the value belongs, select fx, paste the code, and select Add or Update. Enter code in the expression editor, not as ordinary text in the email. Do not add an equals sign or an @ prefix.

Make these changes inside the email action in Apply to each. Here, item() refers to the current Excel row. Save and test after each improvement to see its effect.
Copy the loop-only flow
- Find Purchases from Excel from Lab 4.1—the version that sends an email for every row.
- Use Save As to create a copy named Purchase Improve notification, matching the screenshot.
- Open the copy for editing. Keep the Excel action, Apply to each, and email action.
- After saving your changes, enable the copied flow before testing.
Use the loop-only flow so both remaining rows generate emails. The greater-than-1000 condition from Lab 4.2 is not part of this lab.

Keep two rows and read the file again
- Open the OneDrive copy of PurchaseRequests.xlsx—the file selected in your Excel action.
- Delete the three table data rows for Keyboard, Meeting room screen, and Headset. Keep Monitor and Office chairs.
- Keep the table headers and the PurchaseRequests table name. Delete the rows rather than only clearing their cells.
- Wait for the workbook to finish saving, then run the flow.
- Expand Apply to each in the run result. It should show 1 of 2, rather than 1 of 5.

When this flow runs, List rows present in a table reads the saved file in OneDrive again. It does not keep the five rows from an earlier run. The loop processes the rows returned by that read, so the next run now has two iterations.
Editing the file does not start this manually triggered flow. Save the file, then run the flow again. If you edit it after the Excel action has already read the rows, those edits belong to a later run.

Clean the item name and make the subject uppercase
Open the email action and replace the Item name token in Subject with this expression.
toUpper(trim(item()?['Item name']))item()?['Item name']gets the current row’s item name.trim(...)removes spaces from the beginning and end.toUpper(...)converts the result to uppercase.
The functions work from the inside out. For example, Office chairs becomes OFFICE CHAIRS. The sample names already have no outside spaces, so the visible change is uppercase. Keep the body’s Item name token unchanged to compare the two.
Save, run, and check the subjects of the two new emails.

Add a readable run timestamp
At the bottom of the email body, type created on , then insert this expression using fx.
formatDateTime(utcNow(), 'dd/MM/yyyy HH:mm')utcNow() supplies the current UTC time when evaluated. formatDateTime() displays it using our chosen pattern: day/month/year and a 24-hour time. MM means month; mm means minutes.
This value is UTC. In the screenshot the body shows 11:49 while Outlook displays 2:49 PM in Qatar. The expression formats the timestamp; it does not add Qatar’s three-hour offset. It also represents when the expression is evaluated, not when the Excel request was created.
Save and run again. Check the new timestamp in the latest email.

Calculate a 5% fee
Add a new line after the business reason, type 5% fee: , and insert this expression.
mul(float(item()?['Estimated cost']), 0.05)float() converts the Excel cost to a number. mul(..., 0.05) multiplies it by 5%. This is the fee amount, not the total including the fee.
| Item | Estimated cost | 5% fee |
|---|---|---|
| Monitor | 850 | 42.5 |
| Office chairs | 1500 | 75 |
Save, run, and compare the calculated fee with the current row’s cost. The sample is a training fee calculation.

Provide a fallback when the reason is blank
- Open the same workbook in OneDrive.
- Clear only the Business reason cell for Office chairs. Keep the row, item name, and cost.
- Wait for the workbook to finish saving.
- In the email action, replace the Business reason token with the agreed expression below.

if(empty(item()?['Business reason']), 'No reason Given', item()?['Business reason'])empty(...) checks whether the value is empty. if() returns No reason Given when that check is true; otherwise it returns the row’s original business reason.
This expression returns a value inside an email field. It does not add a separate Condition control or a new branch. A cell containing only spaces is not empty, so clear the cell completely for this test.
Save and run again. Monitor should retain Report preparation, while Office chairs should show No reason Given. Both rows still produce emails.
You did not change the flow’s data-source selection. The next execution reads the same workbook again and sees the newly empty cell. Previous emails remain unchanged; the next emails reflect the current saved data.

Same flow, clearer information.
- Two current table rows produce two emails per run.
- The subject is trimmed and uppercase.
- The body contains a readable UTC timestamp and the calculated 5% fee.
- A blank business reason produces No reason Given.
- You can explain that each run reads the saved OneDrive workbook again.
If something does not work
- Old rows
- Confirm you edited the OneDrive file selected in List rows, not the original download. Wait for saving to finish and start a new run.
- Five iterations
- Delete the unwanted table rows, not just their contents. Check the table’s current extent.
- Code in email
- Insert the code through fx rather than typing it as body text. It should appear as an expression token in the designer.
- Only one email
- Check you copied the loop-only flow, with no cost condition around the email.