Post

#PowerPlatformTip 17: 'Format data by example'

#PowerPlatformTip 17: 'Format data by example'

TL;DR: Format data by examples is deprecated. Its replacement is the Copilot expression assistant: in any field select fx > Create expression with Copilot, describe the output (“Format Created as dd.MM.yyyy”), select Create expression, check the result and add it. Below are three ready-to-use expressions for the classic date, number and text cases.

Writing expressions to format dates, strings and numbers by hand is fiddly and error-prone. Power Automate can write the expression for you. In 2023 that meant giving an example of the wanted output. Today you describe it in plain language.

💡 Challenge

You need 2022-09-18 as September 18 in an email, a Forms number 5958 as $5,958 in Excel, or only Casey out of Casey Jensen. Each of these is one expression, but only if you remember the function names and format strings.

✅ Solution

Let Power Automate generate the expression:

  • Copilot expression assistant (current): available in the new designer for tenants where Copilot is enabled. It creates, updates and fixes expressions from a natural-language prompt. The feature is in preview.
  • Format data by examples (deprecated): Microsoft keeps it supported until removal, but recommends the expression assistant as the replacement. It is also not available in South Africa, GCC High and DoD environments.

🔧 How It’s Done

1. Open the expression editor.

🔸 Select the action, click the input field you want to fill and select fx.

2. Create the expression with Copilot.

🔸 Select Create expression with Copilot.

🔸 Write the prompt and use the names of your dynamic content, for example: Format Created to ‘MMMM d’.

🔸 Select Create expression, then OK to put it into the editor and Add to put it into the field.

3. Check the result against these reference expressions.

🔸 Date 2022-09-18 to September 18:

formatDateTime(triggerOutputs()?['body/Created'], 'MMMM d')

🔸 Number 5958 to $5,958:

formatNumber(5958, 'C0', 'en-US')

🔸 Full name Casey Jensen to Casey:

first(split('Casey Jensen', ' '))

🔸 Replace the literal values with your dynamic content. The body/Created path depends on your trigger.

4. Let Copilot update or fix an expression.

🔸 Open an existing expression, select Create expression with Copilot and describe the change, for example add the year. Copilot uses the loaded expression as context.

🔸 If the loaded expression is invalid, for example a missing parenthesis, the same button proposes the corrected version.

🎉 Result

You get a working formatting expression without looking up function names or format strings, and you can still read and adjust it yourself, because the result is a normal expression.

🌟 Key Advantages

🔸 No syntax lookup: describe the result, get the expression.

🔸 Works on existing expressions: update or fix them with a prompt.

🔸 Plain expressions: the output is standard Workflow Definition Language, no hidden dependency on Copilot at runtime.

🎥 Video Tutorial

🛠️ FAQ

1. I can’t find ‘Format data by example’ anymore, where did it go?

Microsoft deprecated the feature and recommends the Copilot expression assistant in the expression editor instead. Open any field, select fx and then Create expression with Copilot.

2. I don’t see ‘Create expression with Copilot’ either. Why?

The assistant is part of the new designer and only appears in tenants where Copilot is enabled. In that case write the expression yourself; the reference expressions above cover the most common formats.

3. Can I format several fields into one string?

With Copilot, yes: describe the combination, for example Concatenate first name and last name. The old Format data by examples only handled one text, number or date at a time and did not support arrays.

🔸 #PowerPlatformTip 6: ‘formatDateTime in utcNow’ - format a timestamp directly, and the MM vs mm gotcha.

🔸 #PowerPlatformTip 112: ‘Consistent Data Formats’ - keep the expressions you generate consistent across flows and apps.

This tip is by Marcel Lehmann, Microsoft MVP (Business Applications) and founder of the Power Platform Academy – live Power Platform workshops, free or CHF 49. Join the workshop waitlist to get notified about new dates. For companies that want this implemented for them, see KMUpower – Power Platform consulting & automation for SMEs (DACH).

This post is licensed under CC BY 4.0 by the author.

Microsoft and the Power Platform product names (for example Power Apps, Power Automate, Copilot Studio) are trademarks of the Microsoft group of companies. This is an independent website. It is not operated, sponsored or endorsed by Microsoft.