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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / "Non Binary" Boolean V...
Power Apps
Unanswered

"Non Binary" Boolean Variables

(0) ShareShare
ReportReport
Posted on by

Hi All,

 

Apologies if I am using incorrect terminology, I'm rather new to this, so I'll explain what I mean in case my title does not make sense.

 

Is it possible to have a variable in Power Apps that is non-binary, with options other than "true" and "false"? For example, I know that you can do the following:

 

 

Set(varexampletext,"Example Text"

 

 

... and then "Example Text will appear in a Text Input where "varexampletext" is the Default Value.

 

However, I'm thinking along the lines of the following. Imagine I have four buttons on the top of the screen, ButtonA, ButtonB, ButtonC, and ButtonD. I have four containers all occupying the same space on the main body of the screen, ContainerA, ContainerB, ContainerC, and ContainerD. The OnSelect values of the buttons are as follows:

 

 

ButtonA:

Set(varContainerAVis,true):Set(varContainerBVis,false):Set(varContainerCVis,false):Set(varContainerDVis,false)

ButtonB:

Set(varContainerAVis,false):Set(varContainerBVis,true):Set(varContainerCVis,false):Set(varContainerDVis,false)

ButtonC:

Set(varContainerAVis,false):Set(varContainerBVis,false):Set(varContainerCVis,true):Set(varContainerDVis,false)

ButtonD:

Set(varContainerAVis,false):Set(varContainerBVis,false):Set(varContainerCVis,false):Set(varContainerDVis,true)

 

 

The "Visible" field for the Containers is:

 

 

ContainerA:

varContainerVisA=true

ContainerB:

varContainerVisB=true

ContainerC:

varContainerVisC=true

ContainerD:

varContainerVisD=true

 

 

Long story short, considering that only one container need ever be visible at any one time, is the following possible:

 

 

ButtonA:

Set(varContainerVis=A)

ButtonB:

Set(varContainerVis=B)

ButtonC:

Set(varContainerVis=C)

ButtonD:

Set(varContainerVis=D)

 

 

then set the Containers' "Visible" fields to:

 

 

ContainerA:

varContainerVis=A

ContainerB:

varContainerVis=B

ContainerC:

varContainerVis=C

ContainerD:

varContainerVis=D

 

 

Categories:
I have the same question (0)
  • Verified answer
    Rajkumar_M Profile Picture
    3,741 Super User 2025 Season 2 on at

    Hi @ashleynicholson 

     

    Yes, in PowerApps, you can use variables to hold more than just binary values (true/false). You can set a variable to any value, including text, numbers, records, or tables.

     

    For your scenario, you can use a single text variable to control which container is visible. Here's how you can do it:

    Define a variable to hold the current visible container. You can set this variable when a button is clicked.

     

    For each button's OnSelect property, set the variable to a unique identifier for the corresponding container.

    For each container's Visible property, compare the variable to the unique identifier for that container.

     

    Button OnSelect Actions:

     

    ButtonA OnSelect: Set(varContainerVis, "A")
    ButtonB OnSelect: Set(varContainerVis, "B")
    ButtonC OnSelect: Set(varContainerVis, "C")
    ButtonD OnSelect: Set(varContainerVis, "D")

     

    Container Visible Properties:

     

    ContainerA Visible: varContainerVis = "A"
    ContainerB Visible: varContainerVis = "B"
    ContainerC Visible: varContainerVis = "C"
    ContainerD Visible: varContainerVis = "D"

     

    This way, when you click on ButtonA, varContainerVis will be set to "A", and only ContainerA's Visible property will evaluate to true, making it the only visible container. The same logic applies to the other buttons and containers.

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • AN-31011359-0 Profile Picture
    on at

    Thanks very much Rajkumar.

     

    As a follow up, if I wanted to set this variable as a parameter in the URL, how would I approach it?

     

    If I just wanted to set one as true, I would do the following:

     

    App: OnStart: Set(varContainerAVis,Param("paramContainerAVis") = "true");

     

    I have tried the following:  

     

    App: OnStart: Set(varContainerVis,Param("paramContainerVis") = Or("A","B","C","D");

     

    ... but it does not react as expected and I'm unable to the variable as part of the App OnStart. Thanks in advance.

  • Rajkumar_M Profile Picture
    3,741 Super User 2025 Season 2 on at

    The `Param` function in PowerApps is used to retrieve a parameter value from the URL. The value returned by `Param` is always a string, so you need to compare it to the expected string values.

     

    If you want to set `varContainerVis` based on a URL parameter, you should directly assign the value returned by `Param` to `varContainerVis`. There's no need to use the `Or` function in this case, as `Or` is used for logical comparisons, not for assigning one of multiple values.

     

    Here's how you can set `varContainerVis` in the `App: OnStart` property:

     

    Set(varContainerVis, Param("paramContainerVis"));


    This will set `varContainerVis` to the value of the URL parameter `paramContainerVis`. For example, if the app URL is:

    https://apps.powerapps.com/play/your-app-id?paramContainerVis=A

    Then `varContainerVis` will be set to "A".

     

    If you want to ensure that `varContainerVis` is only set to "A", "B", "C", or "D" and not to any other value, you can use an `If` statement to validate the parameter:

     

    Set(varContainerVis, 
    If(
    Param("paramContainerVis") in ["A", "B", "C", "D"],
    Param("paramContainerVis"),
    "Default" // Replace "Default" with whatever default value you want
    )
    );


    This will check if the `paramContainerVis` URL parameter is one of "A", "B", "C", or "D". If it is, it will set `varContainerVis` to that value. If not, it will set `varContainerVis` to "Default" or any other default value you specify.

     

    Thanks!

     

    If my response has been helpful in resolving your issue, I kindly request that you consider clicking "Accept as solution" and "giving it a thumbs up" as a token of appreciation.

  • AN-31011359-0 Profile Picture
    on at

    Thanks very much, you've been a great help!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard