Looping through a table

Moragtao

New Member
Joined
Jun 6, 2019
Messages
1
I'm attempting to create a table to store all of my functions in. What I would like to do is have power query loop through this table and load in all the functions in said table, but I can't seem to find any way to make this happen. I assume there is a way, I just don't know enough yet about power query to make it happen. Does anyone know how to go about doing this, or can point me in the right direction?
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
Hi,

Sorry, I am not good with the formatting on the message board. And the board will not allow me to upload an attachment.

Below is a sample table called calcs that contains Field name, the formula and the type information.
[TABLE="width: 500"]
<tbody>[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]Field[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 238"]
<tbody>[TR]
[TD="width: 238"]Expression[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 30"]
<tbody>[TR]
[TD="width: 30"]Type[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]sum[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 238"]
<tbody>[TR]
[TD="width: 238"]List.Sum({[a],})[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 30"]
<tbody>[TR]
[TD="width: 30"]type number[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
[TR]
[TD][TABLE="width: 64"]
<tbody>[TR]
[TD="width: 64"]subtract[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 238"]
<tbody>[TR]
[TD="width: 238"][a]-[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[TD][TABLE="width: 30"]
<tbody>[TR]
[TD="width: 30"]type number

[/TD]
[/TR]
</tbody>[/TABLE]
[/TD]
[/TR]
</tbody>[/TABLE]

In your query that contains the data, add the boldfaced line.let
Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"a", Int64.Type}, {"b", Int64.Type}}),
AddColumns = List.Accumulate(List.Buffer(Table.ToRecords(Calcs)), #"Changed Type",
(s,c) => Table.AddColumn(s, c[Field], each Expression.Evaluate(c[Expression],[_=_] & #shared ), Expression.Evaluate(c[Type], #shared )))
in
AddColumns



#"Change Type" would be one of your steps in your query. I have not tried this in a real transform yet so I do not know how well it performs. I would think adding the columns in your query would be more efficient. Are you looking to reduce the number of lines in your transform?

Good luck and let me know how it works for you,
Mike
 
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,254
Members
452,624
Latest member
gregg777

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top