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 Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

MPA Licensing.jpg

Ask your licensing questions at the Power Automate AMA!

Join Priya Kodukula and the licensing team, super users and MVPs to find answers to your questions on Power Automate licensing.

Users online (1,708)