I've found when patching data back into a source from a collection, it helps to make sure your collection and source don't have the same column names as PowerApps can't determine the correct scope for the columns. Yes, it's nice and easy if you're just appending and you can collect straight back into the source, but patching is another story it seems.
Creating the collection from the source is also nice and easy with ClearCollect(Collection, Source) - so I figured I'd try use RenameColumns after the fact to differentiate my collected columns from my source columns. That's when the weirdness started;
ClearCollect(StageTable, QTable); ClearCollect(CollectQuestions, RenameColumns(StageTable, "Category", "CollectCat"), RenameColumns(StageTable, "QID", "CollectQID"), RenameColumns(StageTable, "Questions", "CollectQ"))
Here's the staging collection followed by the new collection;
StageTable
New Collection with...???
So, I'm pretty sure it's supposed to rename new columns...What am I doing wrong here?
Kind regards,
R
Solved! Go to Solution.
OK, I think this is what you are looking for:
ClearCollect(StageTable, QTable); ClearCollect(CollectQuestions, RenameColumns(RenameColumns(RenameColumns(StageTable, "Questions", "CollectQ"), "QID", "CollectQID"), "Category", "CollectCat"))
Does it work?
Hi @Anonymous
The result you show is what I would expect with the code you have shown.
Could you please be more specific about what you would expect?
I was expecting a new collection with data from the original source, but with different column names....
Whereas I seem to have added columns instead of just renaming them...
OK, I think this is what you are looking for:
ClearCollect(StageTable, QTable); ClearCollect(CollectQuestions, RenameColumns(RenameColumns(RenameColumns(StageTable, "Questions", "CollectQ"), "QID", "CollectQID"), "Category", "CollectCat"))
Does it work?
It did indeed - I would never have gotten there - thanks!
So i'm guessing you have to only have one update item for RenameColumns meaning you have to nest it - not sure I understand the logic though, any chance you can explain it to me?
With ClearCollect(A, B, C, D) you were collecting B then C then D in A.
The only reason to nest the RenameColumns is that for some reason which is unclear to me RenameColumns only accepts one column to be renamed at a time, so you have to nest three of them. The function should be renamed RenameColumn or fixed to accept more than one column at a time.
Thanks again Meneghino, your answers are always on point. much appreciated.
User | Count |
---|---|
183 | |
110 | |
88 | |
44 | |
42 |
User | Count |
---|---|
229 | |
108 | |
107 | |
68 | |
68 |