Forum Discussion
Multiply multiple columns at once based on list of columns
- 1 year ago
Table.TransformColumns( DataTypeAuto, List.Transform(caLst, (x) => {x, (w) as number => Number.From(w) * 10}) ) - 1 year ago
Hi Goodkat
This is an interesting question and can be done by List.Accumulate using the following formula
= List.Accumulate({"2025 - 1", "2025 - 2"},DataTypeAuto,(a,b)=>
Table.TransformColumns(a,{b, each _ * 10, type number}))Please find your solved file in the attached and dor further details, se my video as bellow
https://www.youtube.com/watch?v=G8PRbWuDcmQ&t=98s&pp=ygUWb21pZGJpIGxpc3QuYWNjdW11bGF0ZQ%3D%3D
Dear AlienSx,
thank you so much for your reply! It worked after a little change. The (w) as number declaration throws 'error' when facing 'null' values. So I tried; do not declare (w) or use (w) as any. Both works. Furthermore with the 'Number.From' I could also skip any previous conversion step!
Your solution is so cool! I will put it to my list of standard solutions!
Stay safe & healthy!
Best regards, Andreas (Brunswick, Germany)
- AlienSx1 year ago
Super User
Hello, Andreas
well, nulls are not a problem: use (w) as nullable number and error disappears.
- Goodkat1 year ago
Helper II
Dear AlienSx,
Super! Thank you for that clarification. I now read about the possible variable declarations and their add-ons in Power Query. The 'as nullable' addition I will put to my notes to never step into that trap again. A super swift solution has been found!
Best regards, Andreas