Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Application specific solutions
    • Dataverse
    • Excel
    • Forms
    • Outlook
    • Planner
    • Power Apps
    • SharePoint
    • Teams
  • Triggers
  • Ready to use solutions
    • Approval Process Solution
    • Task Delegation App
    • The Ultimate Power Automate expressions cheat sheet
    • Power Automate HTTP requests to SharePoint cheat sheet
    • Power Automate HTTP requests to Graph API cheat sheet
  • ABOUT ME
  • Get help with your flow
  • POWER PLATFORM SERVICES
Menu

How to combine expressions in your Power Automate flows

Posted on May 18, 2022May 18, 2022 by Tom

“I know what the expression should do, I just don’t know how to build it! What Power Automate expressions should I use and how to combine them?”


Using expressions is similar to using the existing Power Automate actions. You’ve got these small building blocks, each of them with some functionality, and you combine them together to do a specific task.

While the designer makes it easy to drag and drop actions, with expressions it’s mostly on your shoulders. It gives you more freedom, you’re not limited by the existing actions, but you get also more responsibility. Unless you use the right expression or combination of multiple expressions, the flow won’t work. 

How do you then build the right expression from the small building blocks?

Follow your thought process

Let’s show it on an example – a PDF file with a date in the name, e.g. Tom_Riha_overview_13/05/2022.pdf, and the goal is to rename the file while changing the date format: 2022-05-13_Tom_Riha_overview.pdf. How would you do that using expressions?

Isolate the date string

The first step would be to isolate the date. But Power Automate won’t “just look and see the date”, it doesn’t even know there’s a date. Power Automate sees the whole file name as a text with various characters. If you look on it in the same way, you’ll notice that the date is after the last underscore character. The extraction will take two steps – split(…) the string by the underscore:

split('Tom_Riha_overview_13/05/2022.pdf', '_')

and take only the last(…) value:

last(split('Tom_Riha_overview_13/05/2022.pdf', '_'))

You just reduced the string to: 13/05/2022.pdf. It removed big part of the text, but it still has the file extension. Following the same logic, you can split(…) the result again, this time by a comma:

split(last(split('Tom_Riha_overview_13/05/2022.pdf', '_')), '.')

and take only the first(…) part:

first(split(last(split('Tom_Riha_overview_13/05/2022.pdf', '_')), '.'))

The result of this expression will be the date string alone: 13/05/2022.

Power Automate combine expressions

Convert the string to a date

You know it’s a date and as such it’s easy for you to change its format. But again, Power Automate doesn’t know that it’s a date. That the 13 represents day, 05 month, and 2022 a year. You must tell it that it’s a date and in what format with the parseDateTime(…) expression:

parseDateTime(first(split(last(split('Tom_Riha_overview_13/05/2022.pdf', '_')), '.')), 'en-US', 'dd/MM/yyyy')

Format the date

Now, when the flow knows that the string represents a date and what date it is, you can change its format with the formatDateTime(…) expression:

formatDateTime(parseDateTime(first(split(last(split('Tom_Riha_overview_13/05/2022.pdf', '_')), '.')), 'en-US', 'dd/MM/yyyy'), 'yyyy-MM-dd')

Get the original text and the file extension

You’ve got the date in the right format, what’s left is to add the remaining text from the file name. Again, you must tell the flow which part of the text it should add, it doesn’t know that it already processed the date.

You can use the same approach as when isolating the date. Split(…) by underscore:

split('Tom_Riha_overview_13/05/2022.pdf', '_')

take(…) the 3 pieces before the date:

take(split('Tom_Riha_overview_13/05/2022.pdf', '_'), 3)

and join(…) them back into a string using underscore as the delimiter:

join(take(split('Tom_Riha_overview_13/05/2022.pdf', '_'), 3), '_')

You’ll get also the file extension with a similar approach:

last(split('Tom_Riha_overview_13/05/2022.pdf', '.'))

Put all the pieces together in a single expression

Use the concat(…) expression to put all the pieces together to build the new file name.

concat(
formatDateTime(parseDateTime(first(split(last(split('Tom_Riha_overview_13/05/2022.pdf', '_')), '.')), 'en-US', 'dd/MM/yyyy'), 'yyyy-MM-dd'),
    '_',
    join(take(split('Tom_Riha_overview_13/05/2022.pdf', '_') ,3), '_'),
    '.',
    last(split('Tom_Riha_overview_13/05/2022.pdf', '.'))
)
Power Automate combine expressions

Summary

The final expression probably looks scary, but all we did was to follow a thought process and combine the steps into Power Automate expressions. Slowly, step by step, without any assumptions, using only the visible data. It is maybe a bit extreme example and your expressions will be simpler, but learning to combine expressions together will make it easier to build any flow.

That’s why I included also some common combinations of the expressions into the expressions cheat sheet.


πŸš€ Master Power Automate

Join 2,100+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

πŸš€ Master Power Automate

Join 2,100+ professionals getting actionable Power Automate tutorials, solutions, cheat sheets & tips every week.

No spam. Unsubscribe anytime.

Still exchanging emails to get things approved?

Get the Approval Process solution to skip the hard part and deploy an automated, fully functional approval solution on a SharePoint list in minutes! And then the next one, and the next one...

Approval Template Preview ✨ Learn more ✨

Are your approvals stuck due to unavailable approvers?

Keep your approvals running with the Approval task delegation app! Reassign any existing approval task to another user with a single click - no more waiting for absent approvers!

Power Automate approval task delegation ✨ Learn more ✨

Turn ideas into flows with ease!

Grab the complete Power Automate Cheat Sheet Bundleβ€”everything you need to master expressions, SharePoint HTTP calls, and Graph API in Power Automate.

Cheat Sheet Bundle Preview ✨ Get the Cheat Sheets

Didn't find what you were looking for?
Need to adjust a solution to fit your needs?
Or would you just like to get an assistance from somebody with thousands of hours of experience with Power Automate?

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

©2025 Let's POWER Automate | Theme by SuperbThemes