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 / Bug: Toggle value retu...
Power Apps
Answered

Bug: Toggle value returns in if statement

(0) ShareShare
ReportReport
Posted on by 10

I think I found a bug with if statements. When I make a new powerapp put in the toggle button and then make a Label with this as text value: 

If(Toggle1.TrueText="On",Toggle1.Value,"")

 It returns true if toggle is on an false if toggle is off like expected. When the toggle button is on but I make the Logical test to be false it says false on the label instead of nothing. This is shown in the attached steps recording.

 

The expected output in the label was that it shows nothing. The output in the label was the value of the logical test and not the else value.

Categories:
  • RusselThomas Profile Picture
    4,014 on at

    Hi Mischa,

     

    Could possibly be a bug, or just a very confused automatic type conversion, not sure.  Then again, it could also be 'logical' but I'm leaning towards "bug" myself...

    I'm not sure why it does this, but after playing with it a bit I have a theory...see the following tests;

    Based on the If() construct - If(logical test, true_value, else_value)

     

     

    If(true, true, false)

    1. The logical check = true, the result is the true_value which is true.

     

     

    If(false, true, false)

    2. The locial check = false, the result is the else_value which is false

     

     

     

    If(true, true, "sometext")

    3. The logical check = true, the result is the true_value which is true.

     

     

     

    If(false, true, "sometext")

    4. The logical check = false, the result is the else value which should be "sometext" but comes back as false

     

     

    Here's what I think is happening - when the true_value is a boolean type, PowerApps for some reason is converting the else_value to a boolean type as well and returning the result.  If the result is not explicitly boolean true, it's false.

    In the above, "sometext" is not equal to true, therefore the result is false. 

     

    Confused yet? Try this;

     

    If(false, true, 0) 		result false
    If(false, true, 1) 		result true
    If(false, true, "true") 	result true
    If(false, true, "True") 	result false

    0 can be logically auto-converted to boolean as false - anything greater than 0 is true.

    "true" can be auto-converted to boolean as true - anything else is false.


    This only seems to become apparent when;

    The result of the logical check is false AND the true_value is a boolean.

     

    So I'll go with "bug" for now unless someone else has any logical reason why this should be so 🙂

    By the way, if you need your example to work, as a workaround you can just change the type of the true_value to a string - so;

     

    If(Toggle1.TrueText="On", Text(Toggle1.Value), "")

     

     

    Kind regards,

     

    RT

     

  • Verified answer
    Mischa Profile Picture
    10 on at

    Hi Russel,

     

    Huge thanks for figuring that out! I however keep the same issue even if I try your workaround. I also tried it in a new app again to see if it isn't something in the complete formula. Exactly copying the line you typed there as a workaround doesn't work for me even in a new app.

     

    Edit 1: Oh I found something again just while testing this! If I take the Toggle1.value your workaround actually works. This bug keeps surprising me.

     

    Edit 2: I think I was sleeping ofcourse it gives back the true value if I check on true text. The true text always is the same in that example. So it's not actually a bug.... It totally makes sense. 

     

    Kind regards,

    Mischa

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
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard