Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi folks,
I am looking to figure out how to get a substring of every column in a table with a variable number of columns. My code looks like this but it is not working. It is expected to take a substring beginning with the 3rd character in every column regardless how many columns the table has.
let
Source = myTable,
myColumns = Table.ColumnNames(Source),
#"Replaced Value1" = Table.ReplaceValue(Source,
each myColumns,
each Text.Middle(myColumns,3),
Replacer.ReplaceValue,myColumns)
in
#"Replaced Value1"What am I missing here? I am not really comfortable with using each in PQ.
Thanks.
Solved! Go to Solution.
It's vital to understand use of different each and its different evaluation contextin in different functions.
let
Source = myTable,
myColumns = Table.ColumnNames(Source),
Custom1 = List.Accumulate(myColumns, Source, (s,c) => Table.ReplaceValue(s, each Record.Field(_, c), each Text.Start(Text.From(Record.Field(_, c)), 3), Replacer.ReplaceValue, {c}))
in
Custom1
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
It's vital to understand use of different each and its different evaluation contextin in different functions.
let
Source = myTable,
myColumns = Table.ColumnNames(Source),
Custom1 = List.Accumulate(myColumns, Source, (s,c) => Table.ReplaceValue(s, each Record.Field(_, c), each Text.Start(Text.From(Record.Field(_, c)), 3), Replacer.ReplaceValue, {c}))
in
Custom1
| Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension! |
DAX is simple, but NOT EASY! |
Yes, this works. Thank you !
What would you recommend to read about each? I find Microsoft documentation being very sparse.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!