Power Automate Expressions - Format by Example

January 16th 2024
Back to all blogs

Format by Example in Power Automate allows you to build expressions quicker and easier than before, as you don’t need to know the syntax of the expression you are trying to build. This opens Power Automate to business users who may not have encountered the syntax before, but it also means that everyone who builds Power Automates can reduce their build time.

You can currently use this feature for:

Jump to the video

 

Step-by-step blog

This feature is not available in the new Power Automate designer at the time of this article, but you can still easily switch back to the old designer to use this feature.

To do this, click the toggle in the top left-hand corner of the flow designer screen.

If clicking the toggle doesn’t do anything, you can also access the old designer by changing the last part of the URL. At the end of the URL, it will say v3 = true; change this to v3 = false and refresh the page.

To use the feature, go to the Expressions tab in the dynamic content pop-up and click Format data by examples.

how to find format data by examples

When you click, it will ask what data you want to format based on what is available in your flow. If the data you want to use isn’t there, don’t worry. You can alter the expression it gives you to point to the data you want when you add the expression, so use anything in the meantime.

You then need to provide examples of what the data looks like now and what it needs to look like after the expression has been run.

 

Example 1 – Numbers

For this example, there is an array of numbers with one, two and three digits. The data needs to be in a three-digit format for a system further along in the process, so the one and two-digit numbers need to have leading zeros.

number example

Three examples were provided, one for each type of number in the original array, the more examples given the more accurate the result will be. Power Automate generates the output expression, which you can test before applying.

As mentioned before, if the data you wanted to apply the expression to didn’t show up in the list, you can just replace the data in the given expression with the data you actually need to use, so in this example, you would change the items(‘Apply_to_each’).

 

Example 2 – Strings

In this example, an array of names has been taken from Office 365 data. The strings contain each person’s name, but they also contain the department where they work (some companies may have their Office 365 data set up like this). We will use format by example to remove the department only to have the names.

string example

 

Example 3 – Dates

Lastly, we will look at an example using dates. When using dates from a SharePoint list in Power Automate, they will most likely need formatting into a more readable format. When selecting the data item from a data source like SharePoint and Dataverse, the data options will be the same as the dynamic content you normally use.

If you don’t know what format the date is already in, run the flow but add a terminate step under ‘Get items’ and view the outputs.

date example

As we have seen, format by example is a great way to quickly generate Power Automate syntax to format data how you need it for your processes. It can also be a really good learning tool for newer users of Power Automate to see correct syntax and understand what it is doing to their data. Hopefully, it won’t be too long until the new designer introduces the tool!

 

Video

Blogs not your thing? You can always check out our YouTube channel for loads of great tips, tricks and tutorials.

Author
Sophie Charlwood

Technical Evangelist

Back to all blogs

You might also be interested in...