# Tags **Software** : [[02 - Tags/Software/Power Query]] **Functions** used : [[List.Skip]] [[Table.ColumnNames]] [[list.Accumulate]] [[Table.AddColumn]] [[Record.Field]] [[Excel.Workbook]] **Date** : 18-March-2025 # Description - A great use case for using the powerful m-query iterator function list.accumulate to dynamically add new calculated columns to a output dataset. # Video Link <iframe width="560" height="315" src="https://www.youtube.com/embed/YSzekjZPkHE?si=jTY0Wn4-Iox3KpVK" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe> [GITHUB File Link](https://github.com/jbotes/powerbiTutorials/blob/main/PQ_ListAccum_NewColumns_Video.xlsx) # M-Query ```Query 1 let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], ColumnNames = List.Skip(Table.ColumnNames(Source),1), Custom1 = List.Accumulate(ColumnNames, Source, (state, current)=> Table.AddColumn(state, current & "%", each Record.Field(_,current)/[Portfolio Nr of Stocks], Percentage.Type)) in Custom1 ``` ```Query 2 let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], ColumnNames = List.Skip(Table.ColumnNames(Source),1), Custom1 = List.Accumulate(ColumnNames, Source, (state, current)=> Table.AddColumn(state, current & "%", each Record.Field(_,current)/[Portfolio Nr of Stocks], Percentage.Type)) in Custom1 ``` ## Optional Tags **Tags** : **Technique** : [[Looping]] [[Records to Decompose Problem]]