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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Using a Variable in an...
Power Apps
Answered

Using a Variable in an If Statement

(0) ShareShare
ReportReport
Posted on by 222

Upon creation of a record, I set a global variable called "varRecord". By using this and a ".________", I can utilize all the values in all the fields of the record. For example, varRecord.'Account Name' or varRecord.'Launch Date'

I want to hide a button if the program type equals "ABC Program", but I can't figure out the expression. This expression does not work:

If(equals(VarRecord.'ProgramType'("ABC Program"),true),false, true)

I feel like I'm close. What am I missing?

Categories:
I have the same question (0)
  • Pstork1 Profile Picture
    69,657 Most Valuable Professional on at

    Try the following in the Visible property of the button.

    If(equals(VarRecord.'ProgramType',"ABC Program"),false, true)

     

  • ACPBSCi Profile Picture
    222 on at

    No, that's not working either.

    I wish the "get help for this error" feature was actually helpful. All it says is that the "If" has some invalid arguments. You think?

    Your recommendation makes sense. The syntax makes sense. Is there something different I need to do because of the type of global variable I'm using and the way I'm using it (varRecord.'Program Type')? Am I not able to use it this way?

  • Verified answer
    StormEAnderson Profile Picture
    60 on at

    It may be because 'Program Type' is a choice field, in which case you are not dealing with a string but a record. If that is the case you would need to use the "Value" property within that record. So try either of the following:

    // If the field is a choice / lookup field
    Not(VarRecord.'ProgramType'.Value = "ABC Program")
    // --- evaluates to FALSE when programType is equal to "ABC Program"
    
    // If the field is a text field
    Not(VarRecord.'ProgramType' = "ABC Program")

     

  • ACPBSCi Profile Picture
    222 on at

    GOT IT!

    Not(VarRecord.'Program Type' = "ABC Program")

    There is a space in "Program Type". Gotta use those suggestions when they pop up. You can't trust that you know exactly how it appears.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 356 Most Valuable Professional

#2
11manish Profile Picture

11manish 225 Super User 2026 Season 2

#3
Mohsin Ali Profile Picture

Mohsin Ali 211

Last 30 days Overall leaderboard