Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Danfountain
Helper I
Helper I

Looping creating new columns

Hi,

 

I am slowly trying to build my first function.  I am starting without the parameters and will add them later.

 

I have the below code and basically i want to run the add column for each column provided in the SplitList (two rows in this case).  

 

let

Source = OData.Feed("https://XXXX.crm.dynamics.com/api/data/v9.1/contacts?$select=contactid,statecode,statuscode", null, [Implementation="2.0", IncludeAnnotations="OData.Community.Display.V1.FormattedValue"]),

SplitList = Text.Split("statuscode,statecode",","),
#"Converted to Table" = Table.FromList(SplitList, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Custom" = Table.AddColumn(Source, "statuscode_meta", each Value.Metadata( each Text.From(#"Converted to Table"))[OData.Community.Display.V1.FormattedValue]?)
in
#"Added Custom"

 

Now if i change the custom col to this it works.  So how do i feel the list of columns into this?  Also how do i change the custom so that it is also changing per Splitlist (pref with _Name added at the end).

 

#"Added Custom" = Table.AddColumn(Source, "Custom", each Value.Metadata([statuscode])[OData.Community.Display.V1.FormattedValue]?)

 

Many thanks

 

Dan

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @Danfountain ,

About creating loop columns, you can refer:

  1. Looping in PowerQuery 
  2. Creating Loops/Iterations In Power Query 

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thanks for the links.

 

I am struggling to see how to implement this within my code.  Any suggestions?

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.