cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Please help: Sort gallery, LookUp and AddColumns

I am having a horrible time trying to get a gallery sorted. I think the fundamental problem is that I can't get two tables joined correctly in a collection.

 

I have a button that creates the following collection before nagivating to a new screen and populating a gallery:

ClearCollect(collection,Filter('remoteDB1',person_code=ThisItem.person_code))

Then in the gallery items, I have:

Sort(AddColumns(If(ActiveToggle.Value=true,Filter(collection,begin_date<Today() && Today() <end_date),collection),"customer" ,LookUp('remotedb2',proposal_no=proposal_no,customerID)),customer)

If I look at customer in the gallery, the value is always the first value in the table. The lookup isn't working properly.

 

I've tried adding the customerID column from remoteDB2 directly to remoteDB1 inside the filter function in the first command, but there are close to 10,000 items, so it takes forever. I tried doing adding the columns in the same command outside of the filter (so the filter on remoteDB1 is done first), but that doesn't work.

 

Any help?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: Please help: Sort gallery, LookUp and AddColumns

Hi @kman42 ,

Have you solved your problem?

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Based on the issue that you mentioned, I think this issue is related to the field ambiguity (record scope) within your formula. When you type "proposal_no" within your LookUp function, PowerApps could not identify which data source ("collection" or 'remotedb2') the "proposal_no" field comes from.

Actually, 

 

In order to fix this ambiguity issue, you must specify which data source the "proposal_no" field come from exactly. Currently, within PowerApps, in oder to fix your issue, I think the RenameColumns() function could achieve your needs.

 

More details about record scope in PowerApps, please check the following article:

Record scope

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Highlighted
Dual Super User
Dual Super User

Re: Please help: Sort gallery, LookUp and AddColumns

Hi @kman42 

 

Can you please share a bit more information around where are you creating this collection? I see you are using ThisItem.person_code, is it happening inside a gallery? 
 
Please share a detailed information for your multiple screens in this scenario, so that we can help you better.
Highlighted
Community Support
Community Support

Re: Please help: Sort gallery, LookUp and AddColumns

Hi @kman42 ,

Could you please share a bit more about the ThisItem.person_code formula? Where do you take it?

Could you please share a bit more about the data structure of the collection you created?

 

Based on the issue that you mentioned, I have made a test on my side, please consider modify your formula within the Items property of the Gallery in another screen as below:

Sort(
AddColumns(
If(
ActiveToggle.Value = true,
RenameColumns(Filter(collection, begin_date < Today() && Today() < end_date), "proposal_no", "proposal_no1"),
RenameColumns(collection, "proposal_no", "proposal_no1")
),
"customer" ,
LookUp('remotedb2', proposal_no = proposal_no1, customerID)
),
customer
)

please consider take a try with above formula, then check if the issue is solved.

 

More details about the RenameColumns function in PowerApps, please check the following article:

RenameColumns function

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted
Helper II
Helper II

Re: Please help: Sort gallery, LookUp and AddColumns

Thank you! This has been frustrating me for days and it totally works now!

 

I'm not quite sure why though. Is the idea that you have to disambiguate the name of the lookup field in the condition? Could you elaborate?

 

Thanks!

Highlighted
Community Support
Community Support

Re: Please help: Sort gallery, LookUp and AddColumns

Hi @kman42 ,

Have you solved your problem?

 

If you have solved your problem, please go ahead to click "Accept as Solution" to identify this thread has been solved.

 

Based on the issue that you mentioned, I think this issue is related to the field ambiguity (record scope) within your formula. When you type "proposal_no" within your LookUp function, PowerApps could not identify which data source ("collection" or 'remotedb2') the "proposal_no" field comes from.

Actually, 

 

In order to fix this ambiguity issue, you must specify which data source the "proposal_no" field come from exactly. Currently, within PowerApps, in oder to fix your issue, I think the RenameColumns() function could achieve your needs.

 

More details about record scope in PowerApps, please check the following article:

Record scope

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (10,236)