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 / First condition in If ...
Power Apps
Answered

First condition in If statement is triggering even when other conditions are met.

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello. I am trying to use a dropdown box to create a sort of pagination for my app. However I am having an issue where it is navigating to the first screen which should only be triggered by the first condition, regardless of what condition is met. 
Here is the if statement in the 'OnChange' property of the drop down box. (The box is titled Pagination)

 

If(Pagination.Selected.Value = "1", Navigate(scrAddNomCore, ScreenTransition.None), Pagination.Selected.Value = "2", Navigate(scrAddNomKeyInfo, ScreenTransition.None),Pagination.Selected.Value = "3", Navigate(scrAddNomDetails, ScreenTransition.None), Pagination.Selected.Value = "4", Navigate(scrAddNomCitations, ScreenTransition.None), Pagination.Selected.Value = "5", Navigate(scrAddNomRanking, ScreenTransition.None), Pagination.Selected.Value = "6", Navigate(scrAddNomProposer, ScreenTransition.None), Pagination.Selected.Value = "7", Navigate(scrAddNomValidation, ScreenTransition.None), Pagination.Selected.Value = "7", Navigate(scrAddNomValidation, ScreenTransition.None), Pagination.Selected.Value = "8", Navigate(scrAddNomAttachments, ScreenTransition.None), false)

 

The Items property of the drop down box is: [1,2,3,4,5,6,7,8]

 

It is navigating to the first screen regardless of what value is changed.

Categories:
  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    Hello!

     

    Firstly have you considered using a gallery with data source [1,2,3,4,5,6,7,8], and a label with ThisItem.Value that way you can have the numbers display along the top like page numbers that users are used to rather than a dropdown:

    image.png

    Then you have your Onselect set a variable, maybe called ChosenPage (So that it's not reliant on the gallery on that particular page for it's value)

    image.png

     

    And then expand your onselect formula for the pages:

    image.png

    I've attached the POC app as well,

     

    The principle for Dropdowns is the same - I would have it set a variable that is used to navigate rather than relying on the .selected between pages.

  • NPrice99 Profile Picture
    1,302 on at

    Hi @Anonymous 

     

    Try putting brackets around Pagination.Selected.Value = "1" and all of the other ones.

     

    I have had this problem before with not putting brackets around everything.

     

    Regards

     

    Nigel

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    You should definitely not have to bracket the logic unless it explicitly requires brackets. It's nice to compartmentalize them that way, but it's not a requirement.

     

    So what I would hazard a guess is happening in your App currently is that on the other pages you have a control with a different name - so when you then click that control, it is navigating to page 1, as your control called Pagination on page 1 still has a selected value of 1.

     

    This is why I'd suggest using variables - you can't refer to a control on another page when you are changing a control on a separate page.

     

    Also you have a 7 check twice in your formula 🙂

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Anonymousgood suggestions above.  I personally like the gallery based navigation, but if dropdown is the thing, that's fine too.

    Also, you might want to consider two other things.

    1) Use a Switch statement rather than a bunch of If statements this would be a little cleaner to troubleshoot.

    Switch(Pagination.Selected.Value 
     1, Navigate(scrAddNomCore, ScreenTransition.None), 
     2, Navigate(scrAddNomKeyInfo, ScreenTransition.None),
     3, Navigate(scrAddNomDetails, ScreenTransition.None), 
     4, Navigate(scrAddNomCitations, ScreenTransition.None), 
     5, Navigate(scrAddNomRanking, ScreenTransition.None), 
     6, Navigate(scrAddNomProposer, ScreenTransition.None), 
     7, Navigate(scrAddNomValidation, ScreenTransition.None), 
     8, Navigate(scrAddNomAttachments, ScreenTransition.None))

     

    2) - since you are going to probably use this on every page, you will be faced with copy and past and then, if you need changes...go fix all the places.  This can be prone to error.

    You might want to check out this posting on how to avoid that in your Apps.

     

    Hope this all helps.

     

     

  • iAm_ManCat Profile Picture
    18,256 Most Valuable Professional on at

    ooOooooH! I like it! Toggle-based actioning of any stored code - that will be really useful, thanks for the idea 🙂

  • v-xida-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous ,

    Could you please share a bit more about your issue?

    Do you mean that the first condition in your If function always be true, regardless of other conditions are met?

     

    I have made a test on my side, and don't have the issue that you mentioned. Please consider take a try to modify your formula as below:

    If(
    Pagination.Selected.Value = "1",
    Navigate(scrAddNomCore, ScreenTransition.None),
    Pagination.Selected.Value = "2",
    Navigate(scrAddNomKeyInfo, ScreenTransition.None),
    Pagination.Selected.Value = "3",
    Navigate(scrAddNomDetails, ScreenTransition.None),
    Pagination.Selected.Value = "4",
    Navigate(scrAddNomCitations, ScreenTransition.None),
    Pagination.Selected.Value = "5",
    Navigate(scrAddNomRanking, ScreenTransition.None),
    Pagination.Selected.Value = "6",
    Navigate(scrAddNomProposer, ScreenTransition.None),
    Pagination.Selected.Value = "7",
    Navigate(scrAddNomValidation, ScreenTransition.None),
    Pagination.Selected.Value = "8",
    Navigate(scrAddNomAttachments, ScreenTransition.None)
    )

    In addition, I also agree with @RandyHayes 's thought almost. You could also consider take a try to achieve your needs using Switch function. Please take a try with the following formula:

    Switch(
     Pagination.Selected.Value,
     "1", Navigate(scrAddNomCore, ScreenTransition.None),
     "2", Navigate(scrAddNomKeyInfo, ScreenTransition.None),
     "3", Navigate(scrAddNomDetails, ScreenTransition.None),
     ...
     "8", Navigate(scrAddNomAttachments, ScreenTransition.None)
    )

    Best regards,

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

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 432 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 347

#3
WarrenBelz Profile Picture

WarrenBelz 254 Most Valuable Professional

Last 30 days Overall leaderboard