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 / True/False statement n...
Power Apps
Unanswered

True/False statement not working correctly

(0) ShareShare
ReportReport
Posted on by 46

Good afternoon everyone!

 

I've created a PTO app, and I'm trying to set some conditions.  One of the conditions is that if the user selects "Holiday", then they can only request one day.  I have tried two different methods to add this to my app, and neither are working.  The first was to create a variable called OnlyOneHoliday and set it to true, and a condition of if holiday was chosen and the date total was greater than 1 it would set the variable to false, and the displaymode properties for my Next button would include that OnlyOneHoliday had to be true.  This was the formula I came up with -

Set(OnlyOneHoliday,true);
If((DataCardValue22.Selected.Value = "Holiday") && (PTODateTotal > 1), OnlyOneHoliday = false, OnlyOneHoliday = true)

 

However, no matter what choices I make it always returns OnlyOneHoliday as true.  Is there something I'm missing?  Below is the current code for my Next button condition, if it's just easier to add something to that then I'm all ears.

 

If(!IsBlankOrError(DataCardValue22.Selected) && !IsBlankOrError(DatePickerStartDate.SelectedDate) && !IsBlankOrError(DatePickerEndDate.SelectedDate) && PTODateTotal <= SelectedTimeOffAvailableDays && DatePickerEndDate.SelectedDate >= DatePickerStartDate.SelectedDate && OnlyOneHoliday = true,DisplayMode.Edit,DisplayMode.Disabled)

 

Thanks in advance for any assistance!

Categories:
I have the same question (0)
  • wolenberg_ Profile Picture
    1,476 Super User 2026 Season 1 on at

    Hello @DarkoTheNoob 

    Are you updating the variable to the false value ?

    I think you must updating like this:

    Set(OnlyOneHoliday ,If((DataCardValue22.Selected.Value = "Holiday") && (PTODateTotal > 1),false, true)
    

    And after do this, go ahead with the validation inside the next button.

     

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

    If my reply helped you, please give a 👍
    If it solved your issue, please give a 👍 & accept it as the Solution to help other community members find it.

  • Pstork1 Profile Picture
    69,647 Most Valuable Professional on at

    Is the Next button inside or outside the form where the Datacard is?  Reading values of a DataCard in a form from outside the form tends not to work consistently.  Try setting a label equal to DataCardValue22.Selected.Value  next to the Next button and see if the Holiday value actual shows up.

  • PowerJester Profile Picture
    70 on at

    Hi DarkoTheNoob,

     

    Missing: Set(OnlyOne Holiday,jrue) in the If formula.

     

    Try this:

     

    Set(OnlyOneHoliday, true);
    If((DataCardValue22.Selected.Value = "Holiday") && (PTODateTotal > 1), Set(OnlyOneHoliday,false))

  • DarkoTheNoob Profile Picture
    46 on at

    Hello friends!

     

    @wolenberg_ tried that solution, issue is still persisting

     

    @Pstork1 The Next button is outside of the form, but I do have a label in place that shows DataCardValue22's selected value, and it's working appropriately.  Same with the PTODateTotal, it's returning a number but I can't seem to get the OnlyOneHoliday function to successfully check either one.  Here's what I'm seeing so far -

     

    DarkoTheNoob_0-1711644509581.png

    I've updated the Next button formula to include OnlyOneHoliday = true, and the OnVisible for the page itself has @wolenberg_ 's solution included as well, still returning True for some reason.

  • DarkoTheNoob Profile Picture
    46 on at

    Hi PowerJester!

     

    My apologies for the confusion, I have Set(OnlyOneHoliday,true); in the OnVisible properties of the page itself prior to the formula.

  • Pstork1 Profile Picture
    69,647 Most Valuable Professional on at

    Where are you setting the OnlyOneHoliday value to begin with.  I just tried it and it works if I do this in the OnChange of the dropdown.

    If(Dropdown1.Selected.Value="Holiday",Set(OnlyOneHoliday,true),Set(OnlyOneHoliday,false))

    And this in the Display Mode of the Next button.

    If(OnlyOneHoliday && Value(TextInput1.Text) > 1,DisplayMode.Disabled, DisplayMode.Edit)

    Note, my control names are different, but otherwise it should work.

  • DarkoTheNoob Profile Picture
    46 on at

    I'm setting it in the OnVisible section of the page itself.  I'm wondering if I shouldn't be using DataCardValue22 at all, as it doesn't seem to be returning anything.  Here is a snip of a test I just ran, and it's still returning true (the true is just a text label checking OnlyOneHoliday) -

     

    DarkoTheNoob_0-1711645609491.png

     

  • DarkoTheNoob Profile Picture
    46 on at

    Now I'm all kinds of confused.  I had set a variable of what the PTO Type output should read called SelectedTimeOff.  I changed the formula to do a test, and it's still returning true for some reason??

     

    DarkoTheNoob_1-1711645764266.png

     

  • Pstork1 Profile Picture
    69,647 Most Valuable Professional on at

    I wouldn't use onVisible to set variables if you can help it.  Its very unreliable when used in Preview mode and really only runs once when you are running the actual app. It doesn't run for example if you go to a different screen and come back. That's why I suggested using an If() in the OnChange event of the dropdown to set the variable.

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 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard