Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

If Statement isn't working properly

(0) ShareShare
ReportReport
Posted on by 228

I have the following code assigned to a sharepoint column field that should be hidden if the content of another field doesn't match the value indicated. Below is screenshot. As you can see, the column should only appear when "Email" is selected in the Invoices and Statement Delivery, however, it remains visible regardless of selection.

 

2023-08-23_15-30-49.jpg

Any help is greatly appreciated.

 

  • ShondaT Profile Picture
    228 on at
    Re: If Statement isn't working properly

    I just reread what I wrote and it was very poorly written. I revised it. No need to reread though. LOL Thank you for your response. I hope your day is going well. 🙂

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on at
    Re: If Statement isn't working properly

    Hi @ShondaT - I did not quite understand your description, but well done for figuring out a solution in your own way.

  • ShondaT Profile Picture
    228 on at
    Re: If Statement isn't working properly

    @Amik Prior to hearing back from you I tried doing this: 

     

    (varshowfields=2||varshowfields=-1) && DataCardValue14.SelectedText.Value<>"Assurance"

     

    and it worked. I only have 3 options in the dropdown and "Assurance" is the only one that needs to show different fields. 

     

    I tried just tried your approach, but I couldn't get it to work. This is the column the visibility of the other columns are based on and is the text column I applied "Allowed Values" to. Could that be why your suggestion didn't work?

     

    2023-08-25_7-30-21.jpg

    Also, thanks for the validation. Part of the responsibility within the firm I work for is to build these solutions. I've been able to feel my way around, but I have very surface level knowledge which I'm trying to transition to solid approaches. The only way I can do that is to have an understanding of the different ways to construct various syntax and how those syntax differ based on the column type. Your help with that is so appreciated. 🙂

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on at
    Re: If Statement isn't working properly

    @ShondaT :

     

    ComboBox1.Selected.Value = "Entity" || ComboBox1.Selected.Value = "Individual"

     

    Dropping complex field types is the correct approach. Complex fields like Lookups and Choices are very useful if you are interacting directly with SharePoint because Complex field types are designed for the SharePoint user interface in mind. If the ultimate goal is for users to interact directly with the App, there is little need to use Complex fields.

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Imran-Ami Khan

  • ShondaT Profile Picture
    228 on at
    Re: If Statement isn't working properly

    @Amik that worked to! You're awesome. I'm so sorry to have another question but please know that I appreciate your expertise! What would be the syntax if the visibility was the same for two options? I've tried DataCardValue14.SelectedText.Value="Entity" || "Individual"  but it is only visible when Entity is selected.

    By the way, I decided to change all of my SharePoint Choice columns to text columns and set the options in the app. That seems to work so much better and is an approach I can use as a standard. I don't think there's any benefit it using SharePoint Choice fields in solutions unless I'm missing something.

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on at
    Re: If Statement isn't working properly

    @ShondaT same syntax except you will use DataCardValue15.Selected.Value instead of of DataCardValue15.SelectedText.Value.

  • ShondaT Profile Picture
    228 on at
    Re: If Statement isn't working properly

    @Amik would I have to apply a different syntax if visibility was based on a field that is a sharepoint choice field? The variable would remain the same. 

  • ShondaT Profile Picture
    228 on at
    Re: If Statement isn't working properly

    @Amik it worked perfectly! Thank you so much!

  • Verified answer
    Ami K Profile Picture
    15,665 Super User 2024 Season 1 on at
    Re: If Statement isn't working properly

    @ShondaT - consider wrapping parenthesis around your OR statement, e.g:

     

    (varshowfields = 3 || varshowfields = - 1) && DataCardValue15.SelectedText.Value = "Email"

     

     

    In addition, there is no need to use an IF condition. The above expression will either return Boolean true or false.

     

    ------------------------------------------------------------------------------------------------------------------------------

     

    If I have answered your question, please mark your post as Solved. Remember, you can accept more than one post as a solution.

    If you like my response, please give it a Thumbs Up.

    Imran-Ami Khan

     

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,026 Most Valuable Professional

Leaderboard