7 Expressions

7 one line expressions that could help you in Microsoft Flow

Have you ever wondered why the Expression box in Microsoft Flow is so small? It is because Flow is a low code product and low code means that we don’t need much code. Often a one liner can do the job.Small expression box

Sometimes it is the small things in Microsoft Flow that make it difficult to get the job done! In this post I’m looking at 10 one-line expressions that can help. Most of these on liners will fit in that small expression box.

Expression 1 – Get your workflow run URL

This is one of my favourites that couldn’t miss from this list.


For more details see my post about finding your run Url.

Expression 2 – Format your dates

Formatting dates is easy in Flow

formatDateTime(utcNow(), 'yyyy-MM-dd')

Also see How to find your overdue tasks?

Expression 3 – Get the last X characters from a text

Getting the first X characters is easy using the substring function. The last X characters is slightly harder especially if you don’t know how long the text is. The following expression is your answer:

substring(outputs('Compose'), sub(length(outputs('Compose')), 4),4)

Last 4 characters

Expression 4 – Get that space into a variable

When you set a variable to a space Flow will tell you that the value is empty. the following expression will help you set a variable to a space.

replace("X","X"," ")

Expression 5 – Fix those failing switches

When you use switches in Flow and the switch value is sometimes not set you will find that your flow will fail. If you use the coalesce function you can make sure that you always get a value from a variable or action output. Even if the variable or output isn’t set.

Coalesce function


For more information see Improve your switches.

Expression 6 – Compare those texts

How often do you need to check the value of a text variable or output. A while back I was looking at the extensions of a file name

The below expression returned false:

equals('Pdf', 'PDF')

In the above example I used variables, but for simplicity sake I’m using hard coded strings. To solve my problems I used the toUpper fuction:

equals(toUpper('Pdf'), toUpper('PDF'))

Expression 7 – Have you got any great expressions?

The last expression spot in this post is still available. Have you used any great expressions? Please leave you useful one liners in the comments below.

5 thoughts on “7 one line expressions that could help you in Microsoft Flow

  1. commented on October 14, 2019 by Harsh

    Please give expression to parse something from the string ..
    Example to grep some word from body line of email

    • It would very much depend on the kind of data you would want to extract and the format of the email. I’m not sure that I could give you simply expression for this. You could of course create an Azure function that does the work for you using regular expressions. Then call this function from a flow.

  2. commented on March 22, 2020 by Michael

    What ist the best way to handly long expressions? Using a text editor? Is there an editor with intelliSense?

    • Have you used the new editor yet? The new expression editor is a lot better. You will need to enable the experimental features

      • commented on March 25, 2020 by Michael

        No I had not. Yes, now there is IntelliSense, and the input field is bigger! Cool. Thank you!

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: