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

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
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.
Field

<tbody>
</tbody>
Expression

<tbody>
</tbody>
Type

<tbody>
</tbody>
sum

<tbody>
</tbody>
List.Sum({[a],})

<tbody>

</tbody>


<tbody>
[TD]
type number

<tbody>
</tbody>
[/TD]

[TR]
[TD]
subtract

<tbody>
</tbody>
[/TD]
[TD]
[a]-

<tbody>

</tbody>

[/TD]
[TD]
type number


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


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,213,536
Messages
6,114,202
Members
448,554
Latest member
Gleisner2

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