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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Stoner
New Member

Expand multiple columns with prefix dynamically

Stoner_0-1684717711253.png

I have columns containing table cells in all columns after RangeID. The amount will not be fixed but I can grab a list of column names (done in previous steps). I am looking to expand these columns with the original column name as prefix.

 

Extra Info:

The columns in these table cells will clash with one other (i.e. [Y]{0} has "Column1" and [Z1] might also have "Column1" but they are not to be treated as the same column). The number of columns inside [Y], [Z1], [Z2], & [X] are also not fixed. All columns in [Y] are however, equal (i.e. 5 columns, same name). The same will go for the other columns.

All table cells aligned in the same row will have the same amount of rows (i.e. [Y]{0} has 6 rows, [Z1]{0} and [X]{0} will also have 6 rows). The amount of rows might differ if they are not on the same row.

 

---

Update: I have included the prefix but still need the dynamic expand of columns

= Table.ReplaceErrorValues(
            Table.TransformColumns(
            Source_Sheetdata,
            List.Transform(List.Combine({{"Y"}, Source_SheetZlist, {"X"}}),
            each {_, (x)=>Table.PrefixColumns(x, _)})),
        List.Transform(List.Combine({{"Y"}, Source_SheetZlist, {"X"}}), each {_, null}))

Stoner_0-1684721163070.png

 

 

1 REPLY 1
wdx223_Daniel
Community Champion
Community Champion

try this code after the step in your fisrt pic

NewStep=let a=Table.ColumnNames(PreviousStepName) in Table.Combine(Table.ToList(PrevousStepName,each Table.PromoteHeaders(Table.FromColumns(List.TransformMany(List.Zip({a,_}),each if _{1}=null then {} else if _{1} is table then Table.ToColumns(Table.DemoteHeaders(Table.PrefixColumns(_{1},_{0}))) else {_},(x,y)=>y)))))

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

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.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.