Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Automate - Building Flows
Unanswered

Variable and compose provide different results in IF statement...

(0) ShareShare
ReportReport
Posted on by 23

Hi all, I've experienced a very strange behavior: the same expression when is written in "compose" action and "Set variable" provide different output in IF statement.

Some details: in my case I compare email arrival date with another date (doesn't matter which one, in this case). Initially I tried to initialize 2 variables of type string and then compare dates for email and last day of month using DateFormat function. When setting the variables everything looks good: both outputs are the same as they are expected:

Sergii24_1-1717257292622.png

 

Sergii24_0-1717257270801.png


Now, when I compare them, with the following statement:

Sergii24_3-1717257506151.png

Code view so you can verify that I'm using 2 variables from above:

Sergii24_4-1717257550502.png


the result is false (I expect it to be true!):

Sergii24_2-1717257437762.png


Now, I used compose instead of variables (no other change to the flow):

Using the same code as for variables from above to create compose and indeed get the exact same result

Sergii24_8-1717257784160.png

Sergii24_9-1717257812675.png

 

Now, when I compare them, with the following statement:

Sergii24_5-1717257654699.png

Code view so you can verify that I'm using 2 compose outputs from above:

Sergii24_7-1717257685855.png


I get the correct result!

Sergii24_10-1717257840131.png

 

Any ideas what is going on?

P.S. I've tried using ticks() function as well and again, values in variables are the same (Excel confirms it) but IF statement result is false.

Sergii24_0-1717258033029.png

 

 

  • creativeopinion Profile Picture
    10,439 Super User 2025 Season 1 on at
    Re: Variable and compose provide different results in IF statement...

    @Sergii24 Can you verify there aren't any trailing spaces in either of your variables or Compose actions?

     

    Although these two Compose action outputs look the same, the second one has a trailing space. 

    creativeopinion_4-1717268551846.png

     

    creativeopinion_1-1717268502980.png

    creativeopinion_2-1717268512270.png

    This will result in the condition being false.

    creativeopinion_3-1717268533933.png

     

    Use the trim() function. Wrap the output of both of the Compose actions (or variables) in the trim() function. Run a test.

    creativeopinion_5-1717268586349.png

    Without editing the values in the Compose action, the Condition returns true. 

    creativeopinion_6-1717268660224.png

     

     

    You may be interested in these YT Tutorials:

    7 Functions You Need to Know | ️Expression Essentials: Part 1

     

    In the full tutorial I cover 7 functions you need to know when getting started with expressions.

    1️⃣ empty()

    2️⃣ coalesce()

    3️⃣ equals()

    4️⃣ if()

    5️⃣ concat()

    6️⃣ length()

    7️⃣ split()

     

    I cover how to use these functions in expressions and I’ll also cover common mistakes when it comes to writing expressions and show you a few tips and tricks along the way.

     

    As a beginner or even an intermediate flow builder—expressions can seem a bit complex at first, I’m going to try to simplify it for you. If you want to level up your flows by writing expressions—keep watching!

     

    IN THIS VIDEO:

     What is an Expression?

     What is a Function?

     What Does Wrapping a Function Mean?

     How Do I Insert an Expression?

     How to Use a Compose action

     How to Navigate the Expression Builder with Arrow Keys

     How to use the Expression Tooltip

     Common Mistakes When Writing Expressions

     How to differentiate a null from an empty string

     How to Get Dynamic Content When it’s Not Listed

     How to Use a Get Item Action to Verify Dynamic Content Output

     How to Convert Strings to Lower Case

     How to Troubleshoot the if() Function

     

    ----

    5 Power Automate Troubleshooting FAQs and Helpful Tips for Creating Better Flows

     

    In this Power Automate tutorial, I explore 5 frequently asked questions that pop up when troubleshooting a flow. If you’d like to to level up your Power Automate flow skills and learn how to troubleshoot your Power Automate flow—this tutorial is for you!

     

    IN THIS VIDEO:

     How to troubleshoot a false Condition action result

     How to get dynamic content when it isn’t selectable from the list of dynamic content

     How to troubleshoot an Apply to Each action that isn’t looping through

     How to troubleshoot a skipped Apply to Each action

     How to troubleshoot a Filter Query

     How to use a SharePoint yes/no column in a Filter Query

     How to use Compose actions to troubleshoot a Power Automate flow

     How to troubleshoot multiple emails being sent

     How to troubleshoot multiple Teams messages being sent

     

    Hope this helps!

    If I helped you solve your problem—please mark my post as a solution .
    Consider giving me a 👍 if you liked my response!

    👉 Level up your Power Automate skills by checking out my tutorials on YouTube
    👉 Tips and Tricks on TikTok and Instagram

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Michael Gernaey – Community Spotlight

We are honored to recognize Michael Gernaey as our June 2025 Community…

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 566 Super User 2025 Season 1

#2
David_MA Profile Picture

David_MA 516 Super User 2025 Season 1

#3
stampcoin Profile Picture

stampcoin 492