cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kubo
Frequent Visitor

Sorting gallery by calculated value error

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.

1 ACCEPTED SOLUTION

Accepted Solutions
Kubo
Frequent Visitor

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.

View solution in original post

4 REPLIES 4
rampprakash
Memorable Member
Memorable Member

Hello @Kubo,

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

 

 

 

Kubo
Frequent Visitor

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. 

Hi @Kubo :

Please try:

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

Best Regards,

Bof

Kubo
Frequent Visitor

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.

View solution in original post

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,383)