Hi all,
well…
It’s been a 6 hours trying to understand why this doesn’t work…
So, I have a table with columns and rows.
In two columns I have numbers…
I now create a button to concatenate numbers in both columns into a third one…
If I put in the third column this formula:
If(CPE.Cod provincia=1, “Yes”, “No”)
When the column named CPE.Cod provincia is equal to 1 I well get a “Yes” in my third column but…
If I use a button with the Modify Row action I always get “No”…
The “True” condition is never evaluated…
Then in my button, this code always give me blank results and I dont understand why
ModifyRows(Filter(CPE,Cod provincia <= 9), CPE.CODAUTO, Concatenate(“0”, CPE.Cod provincia))
If anyone understand why this doesn’t work as it should do…
What you want is to modify each row from the filter result separately.
What you’re doing instead is modifying ALL filtered rows with a SINGLE result, which is probably not what you expect it to be. Most likely, CPE.Cod provincia in your Concatenate is the whole column of a table.
P.S. There are probably better ways to solve this, e.g. you can just use LeftPad() to add leading zeros where needed:
I did the ForEach/ModifyRow answer to illustrate what is a very common mistake.
So, again:
Table.Filter(...).ModifyRows(
Column,
Value
)
— it’s to modify ALL selected rows at once with the same Value, e.g. set a checkbox to true.
Table.Filter(...).ForEach(
CurrentValue.ModifyRows(
Column,
Value
)
)
— is to modify each row individually with different values, which can calculate out of CurrentValue (pointing to the currently modified row) or whatnot.