Is there some function that implements CollectOrUpdate logic? For example if table contains a record, filtered by some logical expression, then we will Update() this record, othervise - Collect() new one. Now I have to use the next formula to do this:
If(CountRows(Filter(Pages, Category = TextInput1.Text)) = 0, Collect(Pages, { Category: TextInput1.Text, Page: Value(TextInput2.Text)}), Update(Pages, LookUp(Pages, Category = TextInput1.Text), { Category: TextInput1.Text, Page: Value(TextInput2.Text) }))
If() Count() of matched rows in my Pages collection is 0 then we Collect() new entry. Othervise we Update() or Patch() the entry that LooksUp() by the expression.
But it is kinda bulky, is there more elegant solution?
I don't have a more efficient formula, but you might like the Ctrl+Enter shortcut. It puts a carriage return in the formula bar so that you can add more organization to your formula:
If(CountRows(Filter(Pages, Category = TextInput1.Text)) = 0, Collect(Pages, { Category: TextInput1.Text, Page: Value(TextInput2.Text)}), Update(Pages, LookUp(Pages, Category = TextInput1.Text), { Category: TextInput1.Text, Page: Value(TextInput2.Text) }))
User | Count |
---|---|
257 | |
108 | |
93 | |
57 | |
40 |