Showing results for 
Search instead for 
Did you mean: 
Helper V
Helper V

Getting a simple If statement to work

I have one SharePoint List and one Form in PowerApps.

The list has just one column 'Name'.


How do I get the following If statement to work in the Form DisplayMode property?

If the name of the current logged-in user (varUserName) = name on the SP list, DefaultMode.View otherwise Edit



'SharePoint List',
Name = varUserName


It does not work. :'(


Accepted Solutions
Super User
Super User


IsEmpty() determines if a table does not contain any values and is typically used with a Filter() function.  IsBlank() determines if a record exists and is typically used with Lookup(), as this function looks for a single record matching the criteria. .  

View solution in original post

Super User
Super User




Form display mode:


Solution Specialist
Solution Specialist

Well, there are issues with both your LookUp function and your If function.


What do you want to achieve with your LookUp function? Do you simply want to check if a record exists in your SharePoint list for that user?

Bear in mind that an If function has 3 arguments. The first argument needs to return either true or false (its a logical test). The second argument is what the If function will return if the first argument returns true. The third argument is what the If function will return if the first argument returns false.


Right now your first argument will return a record from SharePoint, which is not true or false. Your second and third arguments are the same, meaning that the return of your whole If function will always be Displaymode.View, regardless of whether the first argument returns either true or false.

@zmansuri Thanks for the prompt reply and suggestions. Much appreciated.

I am sorry but the OnStart script returns a red line, it seems that 'Name' could be found. Even though it's on the SP list. I made sure the list name is correct and I even refreshed the list in the data tab.

Invocation of unknown or unsupported function.

Name isn't valid. This identifier isn't recognized.


Did I do anything wrong?

@KvB1 Thanks for the prompt reply.

You are correct, essentially the SP list is a list of auditors with names.

The displaymode of the Form is determined by this list.

If your name is on the auditors list then you can only view the form (DefaultMode.View), otherwise DeafaultMode.Edit.


Hope it clarifies.

Edit: it's DefaultMode not DisplayMode.  Sorry for the confusion.

Solution Specialist
Solution Specialist

	'SharePoint List',
	Name = varUserName

Try this for your logical test. I'm sure you can figure out what to put for the second and third arguments in the IF function ^^


Basically, IsEmpty will return true if the record you are trying to find isn't there. By putting the ! in front of that we reverse that, so it will return true if there is a record found. We use the LookUp that you provided to give input to the IsEmpty.


So if there is a record found that meets the requirements of your LookUp, the first argument of the IF function will return true.

@KvB1 Thanks mate.

Here's my attempt but the whole thing was highlighted in red. :'(


'SharePoint List',
Name = varUserName)),

Solution Specialist
Solution Specialist

Well, what does it say? 😄 The obvious problem is that 'SharePoint List' isn't the actual name of the sharepoint list you want to use

@KvB1 thanks. 

Yes I know that, I use 'SharePoint List' just as a disguised name for the ease of conversation.  


I think it's my syntax that is wrong somewhere causing the error.

Helpful resources

2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 2022.

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,767)