Is this possible?
Scenario:
- Collection 1 (col1)
ID | Name | Characteristic | Value |
1 | Bob | Hair | Blond |
2 | Sally | Teeth | White |
- Collection 2 (col2)
ID | Characteristic | Order |
1 | Teeth | 1 |
2 | Hair | 2 |
Is there a way to sort col1 by the "Order" column in col2 based on Characteristic?
Characteristic is the only column they have in common.
Thank you!
Solved! Go to Solution.
Hi@
Add a new column in col1 using addcolumn function and lookup the order value into new column records, then sort.
Hi @ericonline
To add to the suggestion made by @Jagadeeshk, you can try it this way:
Sort(
AddColumns(colOne, "Order", LookUp(colTwo, _Characteristic = Characteristic, Order)),
Order, Ascending
)
One suggestion though: either change the name of the Characteristic column in the collection to avoid confusion during the LookUp() or use the RenameColumns() function to do it. The screenshot below shows the output of the code above.
Regards,
Hi@
Add a new column in col1 using addcolumn function and lookup the order value into new column records, then sort.
Hi @ericonline
To add to the suggestion made by @Jagadeeshk, you can try it this way:
Sort(
AddColumns(colOne, "Order", LookUp(colTwo, _Characteristic = Characteristic, Order)),
Order, Ascending
)
One suggestion though: either change the name of the Characteristic column in the collection to avoid confusion during the LookUp() or use the RenameColumns() function to do it. The screenshot below shows the output of the code above.
Regards,
You guys are the best. Thank you for your expertise. AddColumns always trips me up! I can never remember:
1.) Where to add it (during the ClearCollect or the Items property of the Gallery)
2.) The mental model of how it works.
I added it to the Items property of the Gallery. Works great!
Take care
Hi @ericonline
I did it directly in the Items property of the gallery as well. As for where to use the AddColumns(), it all depends on the scenario. I recently used it on a ClearCollect() to add an index column that needed to be generated on demand and then used for navigation purposes throughout the app.