Showing results for 
Search instead for 
Did you mean: 
Not applicable

Bug with global variable

Hi everyone,


I just posted this bug report in Sudden err but no dev changes made 'Types of the specified context variables are incompatible.....' and I don't know why it got rejected. Maybe it was because the thread was old? So I'll open a new one. If something is wrong with this post, please tell me what it is.




All of a sudden, I experienced a bug with global variables. Context Variables are not (yet) effected.


The functions where I used a global variable don't work anymore. Error messages state either: "Function 'xy' has invalid arguments/parameters." or: "invalid argument type" or: "The types of the specified context variables are incompatible with the types specified elsewhere".


The last error message (types incompatible) only appears within the Set() functions. After I removed all but one Set functions (I had only three), this error disappeared at the remaining Set function. But even then every other error stays.


Via the PA web interface, I restored an older version of my app from 2 weeks ago. I know for sure, that everything was working just fine there and no error appeared when I built this old version. Also until today everything worked fine. But since today with the current version as well as with the old version the global variable doesn't work anymore.


Even more strange: Everyone still can use the app without errors. Also the forms etc. affected by the errors work just fine. The errors only appear within the development mode (and preview mode). I still can use the app normally on my Android Smartphone. It also works just fine at my own Windows 10 PC and at the PC of one of my colleagues. The currently published version was made between the 2 weeks old one and the current one. And I also tested to restore this version, of course, but the same errors appeared.

I even changed the Live version today, before the errors came up. Also the last Live version before that worked normal.



I use this global variable to bind one of several data sources (Excel tables) to different forms at runtime. So the users can chose between different news channels to read or write news. To chose between different data sources I included a dropdown menu with the following relevant functions:


    "A-News"; Set(SelectedNewsSource; News_A);
    "B News"; Set(SelectedNewsSource; News_B);
    Set(SelectedNewsSource; News_A)


["A-News"; "B News"]

"News_A" and "News_B" are the data sources (Excel tables on OneDrive for Business).



Every form and element which refers to this data instead refers to the global Variable SelectedNewsSource (at least indirectly via a reference to the corresponding BrowseGallery).



I believe there must be a bug in PA, as the errors now come up even in older versions. The PowerApps Release / Version didn't change over the last three weeks. Based on the version overview for my App the PA version is 2.0.730.


It would be really nice if one could solve the problem. If you need more information I'll try to provide them.


Best Regards,


Not applicable

Hi, @Anonymous.


I did get a notification about your apparently-rejected post and thought it was weird. In any case, I'm not sure if the same bug is causing the problem but I'll put in my thoughts about it.


Regarding this error:

    "The types of the specified context variables are incompatible with the types specified elsewhere".

That message is symptomatic of the main update that happened in PA, the one discussed in the thread before. It was a change from having PA being weakly typed to PA being strongly typed.


This means that having these two statements

Set( x, "This is a string" );
Set( x, 5 )

is invalid now since the first statement assigns x a string and the second statement assigns x a number. Basically, whatever type of the value you set first to a global var, it must stay that way.


Do note that the Set() function, AFAIK, does not add extra columns to the table structure that's set to it on its first assignment, unlike ClearCollect() and Collect(). So, if your two data sources, News_A and News_B, differ in structure (i.e. their columns are different), they're considered two different data types. I might be wrong in this one. The PA dev team might have changed it. They put up so many silent updates/fixes, it's annoying.


Are you sure that your global variables are consistently assigned the same type of data? If yes, then it's probably another bug. If not, fix that first and go from there.


Also -- about this:

    Even more strange: Everyone still can use the app without errors. 

I had a similar experience about that. What caused mine was that there was a difference on what version of PA is loaded on View mode and on Edit Mode. Notice the PowerApps Version Release column on your save/version history? That only applies on View Mode. Basically, Edit Mode always loads the latest version of PA, meaning it always uses the latest version of rules.


Is the PowerApps Version Release value of the version of your app that's working on View but not on Edit the same as the latest release of PowerApps? If so, then the new rules added/changed by the update most likely caused the bug. If not, that's really weird and I can't help you with that because I don't know what happened.


Then again -- PA had switched to being strongly typed only around Summer 2017. This might be an entire new bug.

Not applicable

Thanks for your reply, LoneWoof. I checked the hints you gave me.


Regarding this error: "The types of the specified context variables are incompatible with the types specified elsewhere".

So, if your two data sources, News_A and News_B, differ in structure (i.e. their columns are different),


I put a bit hope in this hint but I cannot find any structural differences between both files. Both use the exact same columns. (Originally they are copies of each other and after that there should have been only content updates - new lines in the table.)



Are you sure that your global variables are consistently assigned the same type of data? If yes, then it's probably another bug. If not, fix that first and go from there.


I used the View > Variables(experimental) function to double check if I forgot any definitions.


I have three definitions (using Set function). They all work the same.

I allready tried to delete all but one Set functions. The other errors other than "The types of the specified context variables are incompatible with the types specified elsewhere" remain. So it still cannot load the data and displays errors like: "invalid argument type".


Basically two of the three set functions are just used to make sure, the data sources are fetched as early as possible and to really make sure that the variable is initiated before first use - befor the user opens the corresponding screen (which still doesn't work as the gallery screen still needs a manual change in the dropdown menu befor it displays any content - but thats a different problem):

    Set(SelectedNewsSource; News_A);

The main definition is the one I posted in the first post - with the switch function for the dropdown menu.




Is the PowerApps Version Release value of the version of your app that's working on View but not on Edit the same as the latest release of PowerApps? If so, then the new rules added/changed by the update most likely caused the bug.


The web version overview states that all app versions from the last 4 weeks are build on PA release 2.0.730. Also the version I build/saved today - while the current PA version should be newer.


I don't know how to get the version information of PA Studio. But as my colleague and I have installed PA Studio from the Microsoft Store on Windows 10, I assume that we have the current version (2.0.733?).

According to the analyse (preview) site on the PA web interface the app is currently (today) used on player version 2.0.730 and on 2.0.733.

2.0.730 has only one active user so it's probably not me and my colleague.


Maybe some differences between 2.0.730 (app version) and 2.0.733 (assumed PA Studio version) could be the reason for this bug.



Then again -- PA had switched to being strongly typed only around Summer 2017. This might be an entire new bug.


Yes, I think you are right and it's a new bug.

Or I made a mistake, I didn't realize. But I really don't know what it could be then. Because at least then it must be something minor which wasn't a problem until last week.

Not applicable

I'm tagging @Hemanth. He posted a solution/explanation of the original error ("...are incompatible...") popped up a few months ago. He might be able to better explain what's happening.


I'm sorry I can't help you with this problem. Hope it works out for you.

Not applicable

Wow... I found a solution myself + highlighted another error and took over an hour to compose the report (even if it's not so rich of technical informations)... and it took someone about 5 minutes to reject it... again. And why is there no link in the profile/settings to at least view my own rejected posts. I first have to go back in browser history - edit/save the post again to get this link just to make sure it got rejected. What a crap.


Well, I'll post it again, maybe it stays this time and maybe it either helps customers or PA developers. But after that I'm gone. I read and post in many different web communities, but never expirienced such a user hostil behaviour.




Regarding this error: "The types of the specified context variables are incompatible with the types specified elsewhere".

So, if your two data sources, News_A and News_B, differ in structure (i.e. their columns are different),



Are you sure that your global variables are consistently assigned the same type of data? If yes, then it's probably another bug. If not, fix that first and go from there. 


I tested this aspect again and found a solution. But I'm still searching the error.


I replaced News_B with a copy of News_A (and also reopend my app and deleted + newly imported the fake News_B as a data source). Everything worked fine now, so the global variable itself cannot be the root of the problem.


Then (with some other knowlege from another error I just fixed) I again took the original News_B and replaced or deleted evere date & time data in there with date/time date I took from the respectiv columns of News_A. This also fixed the error.


The data comes from an by PA automatically generated and manually edited editForm. The DataCard includes a date picer and two dropdown menus to select the time (PA's default layout in such a case). The update function which creats the data that should be stored is:
DateValue2.SelectedDate + Time(Value(HourValue2.Selected.Value); Value(MinuteValue2.Selected.Value); 0)


=> So it actually was a problem with a "structural" difference in both data sources that should be assigned to the variable. This time it just wasn't about columns but about data format within the Excel table.


I still don't know why this error emerged just now after it worked befor.


In News_A I had combined date/time colums with the format (within excel): date ( (German format, in case anyone wonders).

The newer lines/data sets were formated as user defined ( hh:mm).

This difference obviously is no problem for PA.


But News_B maybe was empty when I included it in PA. So maybe the colums weren't formated correctly.

But even in case it was empty at the beginning, I remember that I looked into the data at some point and I remember the formats. So I don't know exactly when or why it happend, but I think at some point PA changed the format of data that was allready stored there by PA earlier.


In the first lines:

The date colums in News_B are either formated as date ( hh:mm) or as default (which in this case was a number like 43077). I am quite sure, that the cells with default format were at some point formated or at least displayed as date. Even if I select them now, Excel's function field at the top doesn't show a date, just the number.


In newer lines:

Every date column in News_B is formated as default (with numbers like 43525,20833).


=> So at least: PA first decided to switch the format at some point in the middle of the tables AND obviously LATER decided that this isn't compatible to the News_A format, which resulted in the error I had.

But this could be my fault as I maybe didn't defined the formats correctly at somepoint.


==> That leads me to the question: Can somebody point me at e.g. some tutorials that explain how to define formats if one uses Excel as data source?



To show you the complete picture I now have to talk about another error. 

In short: I log some activities of the app users in an excel file with the following OnSelect unction:

Navigate(...; ...);;
Collect(UsageStats;{user: User().Email; username: User().FullName; screen: "XY"; function: "News"; notes: ""; date: Now()})

The resulting table again has a date+time column called "date", formated userdefined (DD.MM.YYYY hh:mm). I often looked in this table so I'm really sure whats goining on in there. Until the end of last week everything looked like everyone would expect.


Today I (and every other user) got a error message when opening the app (translated freely):

Error while loading "UsageStats". Answer of server: The requested process is invalid. Error while reading the content of a cell. Reason: Not a legal OleAut date. clientRequestId: ...


When I opened the UsageStats table in Excel I saw that something happend with every date/time-stamp in there from the beginning until today morning. For every timestamp only many "#" were displayed - even after I expandend the width of the column to the max. of 1789 pixel.


After I deleted the corrupt timestamps the error message at start was gone.


=> Above for the original error I wasn't sure if PA changed some already saved, older data (formats). This time I am sure, that PA not only changed data (which shouldn't be changed by PA no matter what as I didn't anywhere used a function to change existing data) but it also corrupted the data in a way that PA itself couldn't handle it anymore.


==> All in all:

  • There must be at least one bug. Because data which should not be changed by PA anymore was corrupted by PA.
  • Different date formats in two data sources make them type incompatible.
  • PA also switched at some point between different date types itself, which resulted in all the errors in my news screens.
  • There wasn't any problem with the global variable itself.
  • I think there could be another bug as PA had no problems with the data sources 4 days ago and then decided to display errors. Even more surprising the errors only occured in Edit/Preview mode, while normal users could interact with the screens and edit the faulty datasource via the PA app. This "bug"(?) could be based on a different data source handling of PA release 2.0.730 and 7.0.733.
Not applicable

Good for you! PA can get nitpicky at times.


Although, I don't know if there exists some documentation regarding defining data types in Excel. As you may have noticed, there is a severe lack of good documentation for PA.


And if this is actually a bug -- I'm tagging @v-micsh-msft and @v-monli-msft so they can see this.


Hope you the best of luck, man.


P.S. I've never experienced getting my posts rejected before. I wasn't even aware there was a mechanism for it. However, I do agree that the UX for this community isn't the best. It isn't that good either.

not sure if this is related but I am experiecing issues with declaring, and setting values for, both global and context variables when used in the 'OnVisible' field for a screen, e.g..


UpdateContext({varCurrentYear: "2017"});
UpdateContext({varCurrentMonth: "September"});


When the screen loads (is made viisble to user) the variable is declared but the values are not applied.....what am I missing here?

Not applicable

@Justin_Reading --

The OnVisible property can be a bit tricky. If you're in Edit Mode, sometimes, the event only gets triggered when you Navigate() to a screen during Preview (not when you open the Preview) or move to it via the screen pane outside of Preview


Thanks for the suggestions. I have already tried all these as well as publishing the app and testing again but still no luck.


Then I went back and checked my code.....wouldn't you know it there was one stray semi-colon in an UpdateContext function further down, but Power Apps didn't display an error.....sigh.

Not applicable

@Justin_Reading --

Oh, god. That happened to me so many times too. Lol. But technically, PA does let you know about the stray semicolon at the end -- with an itty bitty red jagged line under that stray semicolon. (If only the devs were to use their own tools, sigh.)


Thanks for making me laugh, dude. 😄

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (54,524)