Hello Guys,
i have a problem joining two tables in PowerApps. I use SharePoint Lists as my datasources.
These are my tables:
Order
ID | Project | Date | Customer | ... |
1 | P-001-Test | 28.07.2020 | Peter |
OrderPosition
ID | OrderID | Material | Amount | Unit |
1 | 1 | Rubber | 10 | pcs |
2 | 1 | Pen | 20 | pcs |
3 | 1 | Pencil | 10 | pcs |
Since I don't want to drag all the columns from the list "Order" into the list "OrderPosition" i've splitted the lists and would like to join both tables again in a Gallery in PowerApps using the ID from Order and OrderID from OrderPosition.
I'm stuck at the following point:
//At first I'm collection the orders for a specific project based on a filter (Dropdown)
ClearCollect(
colProjects;
Filter(Order;Project="P-001-Test")
);;
//After that i want to collect all the Order positions which have the same OrderID as the ID in my colProjects collection WITHOUT USING IN (can't deal with delegation here)
ClearCollect(
colOrderPosition;
AddColumns(
Filter('OrderPosition';OrderID = colProjects.ID);
"Project";
LookUp(
Order;
ID = 'OrderPosition'[@OrderID]
)
)
);;
The formula above works if i do not the filtering but then unfortunately i get all the rows from my source OrderPosition, eventhough "Project" is blank.
What i want is to get all the orderpositions to my specific project.
Unfortunately there will be a lot of data in this list in a short time, so I want to filter the whole thing by Project or ID from the List Order, so that i do not push tons of data in my app...
Solved! Go to Solution.
@KimBim
I looked at general example of how to JOIN two tables in Power Apps inside a collection.
https://matthewdevaney.com/powerapps-collections-cookbook/join-all-columns-from-another-collection/
Here's what I came up with for you. Please let me know what the result is!
//Add all columns from another table code
ClearCollect(mySolution,
Ungroup(
DropColumns(
AddColumns(
OrderPosition,
"myGroupedColumn",
Filter(
colProjects,
ID=OrderPosition[@OrderID]
)
),
"OrderID"
),
"myGroupedColumn"
)
);
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Rather than joining the lists into a single gallery I would recommend creating a parent child relationship between two galleries.
In the parent gallery list all the records from the order list. Then in the child gallery filter the records from the order position list to show all the records where the OrderID = gallery1.selected.ID. As you select orders in the parent table the appropriate records for the Order Position table will show in the other gallery.
@KimBim
I looked at general example of how to JOIN two tables in Power Apps inside a collection.
https://matthewdevaney.com/powerapps-collections-cookbook/join-all-columns-from-another-collection/
Here's what I came up with for you. Please let me know what the result is!
//Add all columns from another table code
ClearCollect(mySolution,
Ungroup(
DropColumns(
AddColumns(
OrderPosition,
"myGroupedColumn",
Filter(
colProjects,
ID=OrderPosition[@OrderID]
)
),
"OrderID"
),
"myGroupedColumn"
)
);
---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."
Hi @KimBim :
Firstly,let me explain why the code "Filter('OrderPosition';OrderID = colProjects.ID)" not work.
The point is OrderID and colProjects.ID have different data types. colProjects.ID is a table.
Secondly,please try this code:
ClearCollect(
colOrderPosition;
AddColumns(
Filter('OrderPosition';OrderID = First(colProjects).ID);
"Project";
LookUp(
Order;
ID = 'OrderPosition'[@OrderID]
)
)
);;
Or
ClearCollect(
colOrderPosition;
AddColumns(
Filter('OrderPosition';OrderID in colProjects.ID);
"Project";
LookUp(
Order;
ID = 'OrderPosition'[@OrderID]
)
)
);;
Best Regards,
Bof
Hey @mdevaney Thanks for your replay.
Just fell in love with your cookbook. Man, that's awesome.
Unfortunately I still get the error message that certain columns are already in the datasource. For example "Created" or "Created by".
If I modify the query so that I only query the columns that are NOT in both data sources, it works.
So I think for now I can work with it very well.
Thanks a lot! 🙂
User | Count |
---|---|
258 | |
111 | |
95 | |
48 | |
41 |