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 / Navigation with variable
Power Apps
Unanswered

Navigation with variable

(0) ShareShare
ReportReport
Posted on by

Hello All,

 

I need to navigate to the next screen based on different text merged together as shown below.

Set(ProdDir, LookUp(BatchTrack, 'Batch ID'= BatchID1.Text && 'Wafer ID'= WaferID1.Text, Product.Value));

Set(ProdStep, Switch(ProdDir,
 "Prod1",
 LookUp(Prod1, OpCode01 = Value(OpCode1.Text), Step),
 "Prod2",
 LookUp(Prod2, OpCode01 = Value(OpCode1.Text), Step),
 "Trial",
 LookUp(Trial, OpCode01 = Value(OpCode1.Text), Step)
 ));

Set(ProdStage, Switch(ProdDir,
 "Prod1",
 LookUp(Prod1, OpCode01 = Value(OpCode1.Text), Stage),
 "Prod2",
 LookUp(Prod2, OpCode01 = Value(OpCode1.Text), Stage),
 "Trial",
 LookUp(Trial, OpCode01 = Value(OpCode1.Text), Stage)
 ));
Set(Direct, ProdStep & ProdStage);

Navigate(Direct) 

I was expecting having a variable in the navigate function wouldn't be an issue, but it doesn't compile.

 

Any ideas? 

 

Thank you in advance.

 

Rob

Categories:
I have the same question (0)
  • PowerStudent Profile Picture
    150 on at

    Hi,

    The Navigate function in Power Apps does not accept a string variable representing the screen name directly. Instead, it expects a reference to the screen object. You'll need to convert the string variable into a screen reference, which can be done using a Switch function or an equivalent logic structure that maps string values to actual screen objects.

    Here's an example of how you might adjust your code:

     

     

    Set(ProdDir, LookUp(BatchTrack, 'Batch ID' = BatchID1.Text && 'Wafer ID' = WaferID1.Text, Product.Value));
    
    Set(ProdStep, Switch(ProdDir,
     "Prod1",
     LookUp(Prod1, OpCode01 = Value(OpCode1.Text), Step),
     "Prod2",
     LookUp(Prod2, OpCode01 = Value(OpCode1.Text), Step),
     "Trial",
     LookUp(Trial, OpCode01 = Value(OpCode1.Text), Step)
     ));
    
    Set(ProdStage, Switch(ProdDir,
     "Prod1",
     LookUp(Prod1, OpCode01 = Value(OpCode1.Text), Stage),
     "Prod2",
     LookUp(Prod2, OpCode01 = Value(OpCode1.Text), Stage),
     "Trial",
     LookUp(Trial, OpCode01 = Value(OpCode1.Text), Stage)
     ));
    
    // Create a variable that will hold the screen object
    Set(Direct, Switch(ProdStep & ProdStage,
     "Prod1Stage1", ScreenProd1Stage1, // Replace with the actual screen object
     "Prod2Stage2", ScreenProd2Stage2, // Replace with the actual screen object
     "TrialStage3", ScreenTrialStage3 // Replace with the actual screen object
     // Add additional cases as necessary
    ));
    
    // Use the screen object variable in the Navigate function
    Navigate(Direct, ScreenTransition.None) // Choose your desired transition

     

    Replace ScreenProd1Stage1, ScreenProd2Stage2, ScreenTrialStage3, etc., with the actual screen object references in your app.

    By using the Switch function to directly set the Direct variable to the appropriate screen object based on the concatenated string of ProdStep & ProdStage, you can then use this variable with the Navigate function. Remember to maintain consistent naming conventions between the values in ProdStep & ProdStage and the names of your screen objects.

     

     

    For more detailed support, book a consultation call with me here:
    Consultation: https://softwarezone365.com/contact-us
    PowerApps Blogs: https://softwarezone365.com/power-apps


    Should you appreciate my assistance and wish to support my work, you might consider:
    Giving this post a Thumbs Up.
    If applicable, marking it as the Solution.


    Support my work:
    PayPal: https://www.paypal.com/donate/?hosted_button_id=DASYHQAEETD2J


    Contact directly:
    Email: Contact@SoftwareZone365.com
    WhatsApp: https://wa.me/+923087478066


    Best regards,
    Ahmad Raza

  • rob4681 Profile Picture
    on at

    the issue I have is that there will be 100 different screens in my app eventually. Is there no other way around listing them all out?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard