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 / Sorting gallery by cal...
Power Apps
Answered

Sorting gallery by calculated value error

(0) ShareShare
ReportReport
Posted on by 61

Hello,

 

I'm sorting gallery by value calculated in the gallery this way:

 

Sort(
AddColumns(
 DataSource,
 "SortField", 
 DateDiff(Last(Filter(DataSource, PersonColumn.Email = Person.Email)).Created, Today()) - number_column
 ),SortField, Descending)

 

 

To select items in the gallery I'm using usual "Set(varRecord, ThisItem)"

 

Everything works fine until I sort gallery this way. After that I'm getting "incompatible types error" everywhere where I used the varRecord. I suspect this is due to schema difference between gallery and record?

 

Is there any way to filter the gallery with calculated values that would not cause this error?

 

Thank you very much in advance.

Categories:
  • Ram Prakash Duraisamy Profile Picture
    5,891 Super User 2026 Season 1 on at

    Hello @Kubo,

    Hope it won't be an issue, make sure both Form and Gallery contains same DataSource

     

     

     

  • Kubo Profile Picture
    61 on at

    Hi rampprakash, unfortunately it is causing issues. I don't have any form based on the varRecord so I cannot tell if its affecting forms.

    I'm patching record in several places later, it is in the patching and also in the gallery that I'm getting "incompatible types error". Basically anywhere where I used varRecord I'm getting error after using "AddColumns" function. 

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

    Hi @Kubo :

    Please try:

    Sort(
     DataSource,
     DateDiff(Last(Filter(DataSource, PersonColumn.Email = Person.Email)).Created, Today()) - number_column, 
     Descending
    )

    Best Regards,

    Bof

  • Verified answer
    Kubo Profile Picture
    61 on at

    Hi all, thank you very much for your replies. I have sorted the issue by not referencing the record directly when patching but using look up.

     

    Set(varRecord, Patch( datasource, lookup(datasource, varRevordID = ID), {column: "123"})))

     

    This have removed the error from the filtered gallery for some reason.

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 409 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 252 Most Valuable Professional

Last 30 days Overall leaderboard