web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Failing to compare a s...
Power Automate
Answered

Failing to compare a string variable with null

(1) ShareShare
ReportReport
Posted on by 4
Hi guys, I have a condition to compare a variable that has an email address and a null value.  If I enter the empty function, it still needs 'a condition' like 'is qual to' and a value...
the above shows like this in the code:
"type": "If",
  "expression": {
    "and": [
      {
        "not": {
          "equals": [
            "@empty(variables('strUserEmail'))",
            ""
          ]
        }
      }
    ]
  },
 
and if I compare the variable with null, it is always true....
 
How can I check the variable if its null?
Categories:
I have the same question (0)
  • Verified answer
    Michael E. Gernaey Profile Picture
    53,442 Super User 2025 Season 2 on at
     
    I would do this, where you replace myemail with your property
     
     
     
    and then the false expression
     
    Now if its NOT empty you get yes and if it is you get no
     
    And if you want to specifically compare to null
     
    you have to use the Expression null
     
    Where as it looks like you Typed Null
     
    if you want both (which Empty should work by itself)
     
     
    If this helps you, please mark as such and maybe a like :-)
     
    Thanks!!
     
  • BB-18031745-0 Profile Picture
    45 on at
    Not sure if I understand the logic in your expression, but another thing to note is that an empty string ("") is not equal to null.


    If you are simply trying to check if the variable has an email address or is empty, you may need to compare it to an empty string instead.
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    How did you initialize the variable? Are you sure that it is null?
  • Suggested answer
    RP-10041546-0 Profile Picture
    4 on at
    Thanks all for your input.  I created the following:
    which like this in the "Code":
          {
            "equals": [
              "@empty(item()?['System.AssignedTo'])",
              "@true"
            ]
          }
     
    This is working fine now.
     
    The field 'System.AssignedTo' is coming from Azure DevOPS and its empty when it has not been assigned.
     
    I receoved input from another thread which is worth adding here:
    Whenever a string variable is set to a null, Power Automate tries to convert it to an empty string and stores it as “” in the backend. This means the variable is no longer "Null", but it is "Empty". (Yes... this is the weird world of Power Automate).

    Because of this, you need to use the null compare for dynamic field values (comparing them directly as opposed to assigning them to a variable and then comparing the variable) and empty comparison for string variable values .

     
    Thanks to all

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 525 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 324 Moderator

#3
abm abm Profile Picture

abm abm 232 Most Valuable Professional

Last 30 days Overall leaderboard