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 / Weird Variable bug in ...
Power Apps
Answered

Weird Variable bug in large PowerApp - Can't troubleshoot

(0) ShareShare
ReportReport
Posted on by 179

 

Hello, PowerApps geniuses...

 

I am having an app crippling issue that appeared out of nowhere and I can't seem to solve it.  I have a global variable that is used throughout this app (mainly in all of the components and gallery buttons) called varCurrentItem that assigns the current row number from a gallery and then adds it to a collection referencing a Table variable called varMasterPPE (this used to be a collection variable but for performance reasons I recently changed it to a table variable). 

 

The app will work fine, with no issues then all of a sudden it will randomly flag ~ 3000 formulas with an "incompatible types for comparison error" centered around that varCurrentItem variable... which is set in this line of code (the on-select property of a button inside the gallery):

 

Set(varCurrentItem, ThisItem.RowNum);
ClearCollect(colCurrentItem, Filter(varMasterPPE, RowNum = varCurrentItem));

 

This is the code on the items property of the Gallery where the above code resides:

 

 

If(varUserInfoSearchTerm, Search(varUserInfoSearch, comAppAssignGallery.galAssignmentsSearchInput, "AdminName", "BranchInventory", "JobNumber", "UserInfoName", "RepairLocation", "RepairReason"),

If(!varMainEditOpen,
Switch(
 varUserInfoFilterValue,
 "Assign Date", Sort(varUserInfoSearch, DateValue(DateTime), Ascending),
 "Branch", Sort(Filter(varUserInfoSearch, BranchInventory), Descending), 
 "HSE Admin", Sort(Filter(varUserInfoSearch, AdminName), Descending),
 "Job Number", Sort(Filter(varUserInfoSearch, JobNumber), Descending),
 "Name", Sort(Filter(varUserInfoSearch, UserInfoName), Descending), 
 "Repair", Sort(Filter(varUserInfoSearch, RepairStatus), Descending),
 "Return Date", Sort(varUserInfoSearch, DateValue(RepairReturnDate), Ascending), 
 "HSE Admin", Filter(Sort(varUserInfoSearch, AdminName, Descending), AdminName),
 "Supervisor", Filter(Sort(varUserInfoSearch, UserInfoManagerName, Ascending), UserInfoManagerName),
 "Vendor", Sort(Filter(varUserInfoSearch, RepairLocation), Descending),

varUserInfoDefault), 



LookUp(varMasterPPE, RowNum = varCurrentItem)

))

 

 

 

In the LookUp function it highlights the = sign and says "Incompatible type, can't compare number, error"  which seems to indicate varCurrentItem is in error? but as you can see from the snip below, varMasterPPE has a number in the RowNum Column...

 

LeeB_CDN_0-1667843893615.png

 

I have tried everything thinking the app is corrupted, backed up, downloaded and re-imported, reverted to earlier versions it will work for awhile and then for no reason spit out the errors again...

 

Hoping someone has some sort of insight for me??


Thanks in advance as always...

 

 

Categories:
I have the same question (0)
  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @LeeB_CDN 

    What happens if you try RowNum = Value(varCurrentItem)?

  • LeeB_CDN Profile Picture
    179 on at

    @Drrickryp   Thanks for responding! Yeah, I thought it might just be a type mismatch with value, but that is not the case, as varCurrentItem is currently showing "error, no value", and when I add Value() it just says it's expecting a text or number

     

    LeeB_CDN_0-1667850239634.png

     

    But even if I set that variable to a value, it still seems to error out...

     

    I am setting that global variable in multiple galleries on multiple buttons... Could that be an issue for some reason? Note: this is all being done in galleries that exist inside Components

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    @LeeB_CDN 

    Set(varCurrentItem,ThisItem) should work no matter where it is.  It will reset the variable whenever a new Item is selected in a gallery.  Make sure it is not referenced in an UpdateContext({...  Otherwise I don't know why it is doing that.

  • Verified answer
    LeeB_CDN Profile Picture
    179 on at

    @Drrickryp 

    I finally found the issue... where varCurrentItem was contributing as an error (searching through it's variable definitions) I traced it to a separate gallery using the same onselect code in on buttons to select the current items that are stored in another global variable, which I had been setting as blank, all I had to do was populate that variable with data and the issue resolved itself.

    Wow, that threw me for a loop! Definitely learned something today though!

    Thanks for spending the time, appreciate your efforts!

  • Drrickryp Profile Picture
    Super User 2024 Season 1 on at

    marty.jpg

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 530

#2
WarrenBelz Profile Picture

WarrenBelz 459 Most Valuable Professional

#3
Haque Profile Picture

Haque 314

Last 30 days Overall leaderboard