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 / PowerApps gobal variab...
Power Apps
Answered

PowerApps gobal variable returns blank when using IF or Switch statement

(0) ShareShare
ReportReport
Posted on by 17

Hi!

 

I'm having some trouble with a global variable. When I try to set the value using an IF or a Switch statement, it'll return blank. I have different user access levels. When a user opens the app, I lookup the user's email in a table and find the access level (varAccessLevel) (1 for region level and 2 for district level) and the location ID (varTransitNumber). I need to setup the variable varRegionTransitId. If the access is at Region level, varRegionTransitId should be the same as varTransitNumber. If it's district level, then I need to search on another table for the region ID. 

I'm attaching some screenshots of this. Here, when looking at the Switch statement, it shows that it evaluates it correctly (first image), but when looking at the variable, it displays blank (second image). Hope someone can help. Thanks!

 

nramirez03_1-1626453563095.png 

nramirez03_2-1626453633830.png

 

 

 

 

 

Categories:
  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    Where is varTransitNumber being set?    I setup a test with this same formula and had no issues.    You need to make sure that varTransitNumber has a value before setting your varRegionTransitID

  • nramirez03 Profile Picture
    17 on at

    Thanks for your reply! It's all been done in the app OnStart. In lower part of the images I attached, on the first one I show what happens when clicking on the switch function, it evaluates correctly (giving 12153 as the result). I attach it again with the result highlighed in yellow. On the second one, when clicking on varRegionTransitID it shows blank.

    nramirez03_0-1626459982617.png

     

     

    nramirez03_1-1626460017499.png

     

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    In the App OnStart the order of things is crucial, otherwise it can get flaky.   I don't know what all you have running in your App Onstart and if you are using the Concurrent function.

     

    I have run into issues when I have a lot of things happening in the OnStart.   Can you trigger it from somewhere else, like the OnVisible of a screen just to see if it behaves differently?

  • Verified answer
    nramirez03 Profile Picture
    17 on at

    Thanks again for your reply! It looks like the issue was because of a calculated column in the data sources which I used to lookup a value for a previous variable. Thanks again for your help. I really appreciate the time you took to help me!

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 397 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 354

#3
WarrenBelz Profile Picture

WarrenBelz 232 Most Valuable Professional

Last 30 days Overall leaderboard