25 Power Apps IF Function Examples

25 Power Apps IF Function Examples

The Power Apps IF Function performs a logical comparison to see if the result is true. Then it conditionally executes the next lines of code based on whether the result was true or false. The examples on this page show how the Power Apps IF Function works for every data type.

Important note: for most examples the IF Function the 2nd argument is true and the 3rd argument is false. These true and false values are only placeholders. They should be replaced with your own code in the real-world.

Table of Contents

• IF Function Text Examples In Power AppsIF Text Value EqualsIF Text Value ContainsIF Text Value StartsWithIF Text Value Is BlankIF Text Value Equals With Multiple ConditionsIF Function Number Examples In Power AppsIF Number Value Is Greater Than Or Less ThanIF Number Value Is Greater Than Or Equal To/Less Than Or Equal ToIF Number Value Does Not EqualIF Number Value Is Between Two ValuesIF Number Is Found Within A Range (Multiple Conditions)IF Function Date Examples In Power AppsIF Date Value Equals Current DateIF Date Value Equals A Specific DateIF Date Value Is Between Two DatesIF Function Boolean Examples In Power AppsIF Boolean Value Equals trueIF Boolean Value Equals falseIF Function Choice Column Examples In Power AppsIF Choice Column Value EqualsIF Function LookUp Column Examples In Power AppsIF LookUp Column ID EqualsIF LookUp Column Value EqualsIF Function Person Column Examples In Power AppsIF Person Column Equals Current UserIF Person Column Equals User NameIF Person Column Equals User EmailAdditional IF Function Examples For Power AppsIF Condition Using AND Logical OperatorIF Condition Using OR Logical OperatorIF Condition Using NOT Logical OperatorIF Condition Using Multiple Logical Operators




IF Function Text Examples In Power Apps


IF Text Value Equals


Input:

Set(varManufacturer, "Samsung")


Code:

Check if varManufacturer equals Samsung

If(varManufacturer ="Samsung", true, false)


Output:

true




IF Text Value Contains


Input:

Set(varTitle, "Dishwasher")


Code:

Check if varTitle contains “wash”

If("wash" in varTitle, true, false)


Output:

true




IF Text Value StartsWith


Input:

Set(varTitle, "Kitchen Sink")


Code:

Check if varTitle starts with “Kitchen”

If(StartsWith(Title, "Kitchen"), true, false)


Output:

true




IF Text Value Is Blank


Input:

Set(varManufacturer, Blank())


Code:

Check if varManufacturer is blank

If(IsBlank(varManufacturer), true, false)



Output:

true




IF Text Value Equals With Multiple Conditions


Input:

Set(varTitle, "Kitchen Sink")


Code:

Check multiple conditions and return the result where varTitle is equal to “Kitchen Sink”

If(
    varTitle = "Dishwasher",
    "Dishwasher was found!",
    varTitle = "Kitchen Sink",
    "Kitchen Sink was found!",
    varTitle = "Refrigerator",
    "Refrigerator was found!",
    "No matches found"
)


Output:

"Kitchen Sink was found!"




IF Function Number Examples In Power Apps


IF Number Value Is Greater Than Or Less Than


Input:

Set(varQuantityInStock, 15)


Code:

Check if varQuantityInStock is greater than 10

If(varQuantityInStock > 10, true, false)


Output:

true




IF Number Value Is Greater Than Or Equal To/Less Than Or Equal To


Input:

Set(varQuantityInStock, 8)


Code:

Check if varQuantityInStock is less than or equal to 10

If(varQuantityInStock <= 10, true, false)


Output:

true




IF Number Value Does Not Equal


Input:

Set(varQuantityInStock, 2)


Code:

Check if varQuantityInStock does not equal 9

If(varQuantityInStock <> 9, true, false)


Output:

true




IF Number Value Is Between Two Values


Input:

Set(varQuantityInStock, 6)


Code:

Check if varQuantityInStock is between 5 and 10

If(
    varQuantityInStock >= 5
    And varQuantityInStock <= 10,
    true,
    false
)



Output:

true




IF Number Is Found Within A Range (Multiple Conditions)


Input:

Set(varQuantityInStock, 5)


Code:

Check multiple conditions and return the result where varQuantityInStock is greater than 0 but less than 10.

If(
    varQuantityInStock >= 50,
    "Too many in stock",
    varQuantityInStock >= 10,
    "Item is in stock",
    varQuantityInStock > 0,
    "Low inventory, time to re-stock",
    "No inventory left"
)


Output:

"Low inventory, time to re-stock"




IF Function Date Examples In Power Apps


IF Date Value Equals Current Date


Input:

Set(varLastSoldDate, Today())


Code:

Assuming the current date is March 6, 2023, check if varLastSoldDate equals today

If(varLastSoldDate = Today(), true, false)



Output:

true




IF Date Value Equals A Specific Date


Input:

Set(varLastSoldDate, Date(2023, 3, 1))


Code:

Check if LastSoldDate column equals March 1, 2023

If(varLastSoldDate = Date(2023, 3, 1), true, false)


Output:

true




IF Date Value Is Between Two Dates


Input:

Set(varLastSoldDate, Date(2023, 3, 10))


Code:

Check if varLastSoldDate is between March 1, 2023 and March 31, 2023

If(
    varLastSoldDate >= Date(2023, 3, 1)
    And varLastSoldDate <= Date(2023, 3, 31),
    true,
    false
)



Output:

true




IF Function Boolean Examples In Power Apps


Boolean Value Equals true


Input:

Set(varOnSale, true)


Code:

Check if varOnSale equals true

If(varOnSale, true, false)


Output:

true




IF Boolean Value Equals false


Input:

Set(varOnSale, false)


Code:

Check if varOnSale equals false

If(!varOnSale, true, false)


Output:

true




IF Function Choice Column Examples In Power Apps


IF Choice Column Value Equals


Input:

Inventory SharePoint List

IDTitleOrderStatus
1DishwasherOrdered
2FreezerOrdered
3Kitchen FaucetNot Ordered
4Kitchen SinkDiscontinued
5RefrigeratorOrdered
6StoveNot Ordered


Get the first row in the Inventory SharePoint list where OrderStatus is a Choice type column

Set(varInventoryItem, LookUp(Inventory, ID=1))


Code:

Check if the OrderStatus of varInventoryItem equals “Ordered”

If(varInventoryItem.OrderStatus.Value = "Ordered", true, false)



Output:

true




IF Function LookUp Column Examples In Power Apps


IF LookUp Column ID Equals


Input:

Inventory SharePoint List

IDTitleManufacturer
1DishwasherLG
2FreezerSamsung
3Kitchen FaucetKohler
4Kitchen SinkAmerican Standard
5RefrigeratorSamsung
6Stove


Manufacturers SharePoint List

IDTitle
1LG
2Samsung
3Kohler
4American Standard


Get the 3rd row in the Inventory SharePoint list where Manufacturer is a Lookup type column

Set(varInventoryItem, LookUp(Inventory, ID=3))

Code:

Check if the ID of varInventoryItem equals 3

If(Manufacturer.ID = 3, true, false)



Output:

true




IF LookUp Column Value Equals


Input:

Inventory SharePoint List

IDTitleManufacturer
1DishwasherLG
2FreezerSamsung
3Kitchen FaucetKohler
4Kitchen SinkAmerican Standard
5RefrigeratorSamsung
6Stove


Manufacturers SharePoint List

IDTitle
1LG
2Samsung
3Kohler
4American Standard


Get the 4th row in the Inventory SharePoint list where Manufacturer is a Lookup type column

Set(varInventoryItem, LookUp(Inventory, ID=4))

Code:

Check if the Title of varInventoryItem equals “American Standard”

If(Manufacturer.Value = "American Standard", true, false)



Output:

true




IF Function Person Column Examples In Power Apps


IF Person Column Equals Current User


Input:

Inventory SharePoint List

IDTitleBuyer
1DishwasherMatthew Devaney
2FreezerSarah Green
3Kitchen FaucetMatthew Devaney
4Kitchen SinkDavid Johnson
5RefrigeratorDavid Johnson
6StoveAlice Lemon


Get the first in the Inventory SharePoint list where Buyer is a Person type column

Set(varInventoryItem, LookUp(Inventory, ID=1))


Code:

Assuming the current user is Matthew Devaney, check if the Buyer of varInventoryItem equals the current user

If(varInventoryItem.Buyer.Email = User().Email, true, false)



Output:

true




IF Person Column Equals User Name


Input:

Inventory SharePoint List

IDTitleBuyer
1DishwasherMatthew Devaney
2FreezerSarah Green
3Kitchen FaucetMatthew Devaney
4Kitchen SinkDavid Johnson
5RefrigeratorDavid Johnson
6StoveAlice Lemon


Get the 2nd row in the Inventory SharePoint list where Buyer is a Lookup type column

Set(varInventoryItem, LookUp(Inventory, ID=2))


Code:

Check if the Buyer column of varInventoryItem has a user name equal to “Sarah Green”

If(varInventoryItem.Buyer.'Display Name = "Sarah Green", true, false)



Output:

true




IF Person Column Equals User Email


Input:

Inventory SharePoint List

IDTitleBuyer
1DishwasherMatthew Devaney
2FreezerSarah Green
3Kitchen FaucetMatthew Devaney
4Kitchen SinkDavid Johnson
5RefrigeratorDavid Johnson
6StoveAlice Lemon


Get the 5th row in the Inventory SharePoint list where Buyer is a Person type column

Set(varInventoryItem, LookUp(Inventory, ID=5))


Code:

Check if the Buyer column of varInventoryItem has an email equal to “[email protected]

If(varInventoryItem.Buyer.Email = "[email protected]")



Output:

true




Additional IF Function Examples For Power Apps


IF Condition Using AND Logical Operator


Input:

Inventory SharePoint List

IDTitleManufacturerOnSale
1DishwasherLGYes
2FreezerSamsungNo
3Kitchen FaucetKohlerNo
4Kitchen SinkAmerican StandardNo
5RefrigeratorSamsungYes
6StoveNo


Get the 1st row in the Inventory SharePoint list where Manufacturer is a text column and OnSale is a Yes/No type column

Set(varInventoryItem, LookUp(Inventory, ID=5))


Code:

Check if varInventoryItem has a Manufacturer equal to “Samsung” and an OnSale column equal to Yes.

If(
    varInventoryItem.Manufacturer="Samsung"
    And varInventoryItem.OnSale,
    true,
    false
)


Output:

true




IF Condition Using OR Logical Operator


Input:

Inventory SharePoint List

IDTitleManufacturerOnSale
1DishwasherLGYes
2FreezerSamsungNo
3Kitchen FaucetKohlerNo
4Kitchen SinkAmerican StandardNo
5RefrigeratorSamsungYes
6StoveNo


Get the 2nd row in the Inventory SharePoint list where Manufacturer is a text column and OnSale is a Yes/No type column.

Set(varInventoryItem, LookUp(Inventory, ID=2))


Code:

Check if varInventoryItem has a Manufacturer equal to “Samsung” or an OnSale column equal to Yes.

If(
    varInventoryItem.Manufacturer="Samsung"
    Or varInventoryItem.OnSale,
    true,
    false
)


Output:

true




IF Condition Using NOT Logical Operator


Input:

Inventory SharePoint List

IDTitleManufacturerOnSale
1DishwasherLGYes
2FreezerSamsungNo
3Kitchen FaucetKohlerNo
4Kitchen SinkAmerican StandardNo
5RefrigeratorSamsungYes
6StoveNo


Get the 3rd row in the Inventory SharePoint list where Manufacturer is a text column and OnSale is a Yes/No type column.

Set(varInventoryItem, LookUp(Inventory, ID=3))


Code:

Check if varInventoryItem has a Manufacturer column not equal to “Samsung”

If(Not(varInventoryItem="Samsung"), true, false)


Output:

true




IF Condition Using Multiple Logical Operators


Input:

Inventory SharePoint List

IDTitleManufacturerOnSale
1DishwasherLGYes
2FreezerSamsungNo
3Kitchen FaucetKohlerNo
4Kitchen SinkAmerican StandardNo
5RefrigeratorSamsungYes
6StoveNo


Get the 1st row in the Inventory SharePoint list where Manufacturer is a text column and OnSale is a Yes/No type column

Set(varInventoryItem, LookUp(Inventory, ID=1))


Code:

Check if varInventoryItem has a Manufacturer column equals “Samsung” and OnSale equals Yes or the Manufacturer column equals “LG”

If(
    (
        varInventoryItem.Manufacturer="LG"
        And varInventoryItem.OnSale="Yes"
    )
    Or varInventoryItem.Manufacturer="LG"),
    true,
    false
)



Output:

true





Questions?

If you have any questions or feedback about 25 Power Apps IF Function Examples please leave a message in the comments section below. You can post using your email address and are not required to create an account to join the discussion.

Matthew Devaney

Subscribe
Notify of
guest

21 Comments
Oldest
Newest
Inline Feedbacks
View all comments
Alexsolex
Alexsolex
9 months ago

I try to explain to all new powerapps developers or citizens that writing “if(my condition,true,false)” is useless and make the readability of code worse.
Can you tell us if there is a real need of this syntax when writing just “myCondition” in a Boolean field is enough ?

Andrea
Andrea
9 months ago

Hi Matthew. Really handy list, thank you.

I’m not sure if you also do this, but when I have a conditional with OR like this:

If(varInventoryItem=”Samsung” Or varInventoryItem=”LG” , true, false)

I prefer to write it as:

If(varInventoryItem in [“Samsung” , “LG”] , true, false)

as it makes it easier to read and to add more items to the list (in this case, of Manufacturers).

What do you think?

Cheers,
Andrea

Jérôme Rancourt
Jérôme Rancourt
9 months ago

Hi Matthew, I tried to modify nested if in power automate following what is explained on this article and could not save the compose action….

First, i created Initialize variable action of string type ‘varTransport’ and the value is based on a Msforms Input

Then a compose action : if(“Train” in variables(‘varTransport’),true,”Autobus” in variables(‘varTransport’),true,”Location automobile” in variables(‘varTransport’),true,false)

Am I missing something ?
Thanks,

Heidi
Heidi
9 months ago

I wish this article had of existed when I started my PowerApps journey 2 years ago. It would have saved me many tears. Especially the logical operators section. Will be sharing this with the up and comers I am mentoring.

Drew Thompson
8 months ago

Hi Matthew:

Thanks for this – did not realize that there was a switch style statement as you showed in Check multiple conditions!

cheers

Pete Filicetti
Pete Filicetti
8 months ago

Matthew,
I’m a huge fan of your work. Thanks for everything you do.

In reading the article, I had a question:

Code:
Check if the Buyer column of varInventoryItem has a user name equal to “Sarah Green”

If(varInventoryItem = Buyer.’Display Name’, true, false)

Wouldn’t it be as follows?:
If(varInventoryItem.Buyer.’Display Name’ = “Sarah Green”, true, false)

Best,
Pete

LDK
LDK
8 months ago

Check if the OrderStatus of varInventoryItem equals “Ordered”

If(varInventoryItem.OrderStatus.Value, true, false)

should this code like below

If(varInventoryItem.OrderStatus.Value = "Ordered", true, false)

thank you for your great posting

Fernando Hunth
Fernando Hunth
8 months ago

I think this Output is not ok:

If(!varOnSale, true, false)

Oscar
Oscar
8 months ago

I tried this syntax but did not get the desired result. I ended up using a switch.
Also, it works if I treat it with nested If statements. Has something changed since you wrote this?
If(
varTitle = “Dishwasher”,
“Dishwasher was found!”,
varTitle = “Kitchen Sink”,
“Kitchen Sink was found!”,
varTitle = “Refrigerator”
“Refrigerator was found!”,
“No matches found”
)

Lütfi
7 months ago

Hi @Matthew,

Sorry for late reply, correct me if I am wrong but this code that you on example shouldn’t return false?

Regards

If(
    varInventoryItem.Manufacturer="Samsung"
    And varInventoryItem.OnSale,
    true,
    false
)
Sindiswa
Sindiswa
6 months ago

If(
  IsBlank(DataCardValue35.SelectedItems),Set(varTask,true),
  IsBlank(DataCardValue1.SelectedItems),Set(varApplicationArea,true),
  IsBlank(DataCardValue36.SelectedItems),Set(varTimein,true),
  IsBlank(DataCardValue40.SelectedItems),Set(varTimeout,true), 
  TimeValue( DataCardValue36.Selected.Value)>=TimeValue(DataCardValue40.Selected.Value), Set(varLabel11, true),Set(varLabel11, false) Or

IsBlank(DataCardValue8.SelectedItems),Set(varTask,true),
  IsBlank(DataCardValue2.SelectedItems),Set(varApplicationArea,true),
  IsBlank(DataCardValue4.SelectedItems),Set(varTimein,true),
  IsBlank(DataCardValue5.SelectedItems),Set(varTimeout,true), 
  TimeValue( DataCardValue4.Selected.Value)>=TimeValue(DataCardValue5.Selected.Value), Set(varLabel11, true),Set(varLabel11, false),

  IsBlank(DataCardValue10.SelectedItems),Set(varTask,true),
  IsBlank(DataCardValue3.SelectedItems),Set(varApplicationArea,true),
  IsBlank(DataCardValue14.SelectedItems),Set(varTimein,true),
  IsBlank(DataCardValue15.SelectedItems),Set(varTimeout,true), 
  TimeValue( DataCardValue14.Selected.Value)>=TimeValue(DataCardValue15.Selected.Value), Set(varLabel11, true),Set(varLabel11, false),
  
  IsBlank(DataCardValue7.SelectedItems),Set(varTask,true),
  IsBlank(DataCardValue17.SelectedItems),Set(varApplicationArea,true),
  IsBlank(DataCardValue29.SelectedItems),Set(varTimein,true),
  IsBlank(DataCardValue24.SelectedItems),Set(varTimeout,true), 
  TimeValue( DataCardValue29.Selected.Value)>=TimeValue(DataCardValue24.Selected.Value), Set(varLabel11, true),Set(varLabel11, false),
  

This is my if statement but its not working says can’t evaluate formula. I have 4 forms and in each I want to validate if the forms aint blank and that time in and time out can’t be the same. Please help