cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dylan_r
Frequent Visitor

empty(variables('var')) is equal to true - returns incorrect values... sometimes

Basic overview:

Getting values from excel spreadsheet to put into a sharepoint list, but I need to check if the value is null, otherwise the list (i.e. the column Person / Group) throws error and doesnt add the entry.

 

So - I created the variable "OwnerField" which gets populated with a persons name, but on occassion, there is no person - so I have a condition to see if that variable is empty > condition Yes or No - if true, then populate with "No user assigned" if false, then it has a value - which is that variable's value.

 

This works - until it doesnt. 😞

 

E.g. My variable input is blank, but my condition is false.  The next entry, my variable input is blank, but my condition is true.  (see attached) 

 

Value 7 is correct! it satisfies condition with result true, and then pastes in as expected

 

CaptureValue7.PNG

 

Value 6 is not correct - its blank, but still satisfies false

CaptureValue6.PNG

 

Any help is greatly appreciated

2 REPLIES 2
eliotcole
Super User
Super User

Have you tried placing a second row in the condition, @dylan_r?

 

So one row with nothing in the right side, and the second with the expression:

null

Then ensure it's an OR expression.

 

However you could avoid using an Apply to each by setting OwnerField from INPUT_VALUE using this expression:

if(
    or(
        equals(
            INPUT_VALUE, 
            ''
        ), 
        equals(
            INPUT_VALUE, 
            null
        ), 
        empty(
            INPUT_VALUE
        )
    ), 
    'No user assigned', 
    INPUT_VALUE
)

 

Below I've got examples of both approaches, the longer expression inside a Select to avoid any loops.

example.jpg

I realise that my sample data, and what I'm filling my OwnerField with may not be what you're doing, but that's irrelevant, essentially you can get done what you want using this approach. 🙂

 

Each way works, and the Select produces a nice little set of data to boot 🙂:

[
  {
    "inputValue": "",
    "OwnerField": "No user assigned"
  },
  {
    "inputValue": null,
    "OwnerField": "No user assigned"
  },
  {
    "inputValue": "frank",
    "OwnerField": "frank"
  }
]

👍

Hi eliotcole,

 

Thank you for your time and reply - I will give this a shot and let you know! thanks again!😀

Helpful resources

Announcements
Power Automate News & Announcements

Power Automate News & Announcements

Keep up to date with current events and community announcements in the Power Automate community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Automate Community Blog

Power Automate Community Blog

Check out the latest Community Blog from the community!

Users online (4,793)