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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
siva_powerbi
Helper IV
Helper IV

Concatenating dynamic column name to table - Power Query

I am trying to create lists of data using dynamic columns, fetching the column name and appending it to the table.

 

Here is the problem as this step is throwing error:

 

Expression.Error: We cannot apply operator & to types Table and Text.

 

Details:
Operator=&
Left=[Table]
Right=Test1

 

Code:

 

let
Source = Excel.Workbook(File.Contents("C:\Users\Sivakumar A\Desktop\Power BI\test1.xlsx"), null, true),
Sheet2_Sheet = Source{[Item="Sheet2",Kind="Sheet"]}[Data],
#"Promoted Headers" = Table.PromoteHeaders(Sheet2_Sheet, [PromoteAllScalars=true]),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Test1", type text}, {"Test2", Int64.Type}, {"Test3", Int64.Type}, {"Test4", Int64.Type}}),
#"Col Names" = Table.ColumnNames(#"Changed Type"),
#"Generate" = List.Generate(() => [i=-1,x= Table.FromList(#"Col Names",Splitter.SplitByNothing())],
each [i]<List.Count(#"Col Names"),
each [
i=[i]+1,
x=#"Promoted Headers"&#"Col Names"{i}

],
each [x])
in
Generate

 

I need to extract the column names and append it to the talble and execute in loop

 

Any help is appretiated.

1 ACCEPTED SOLUTION

@MFelix Thanks for referring the post.

I was able to solve the issue using double quite 3 times.

"Table.Distinct(Table.FromList(#"&"""Sheet2 (2)"""&"["&#"Col Names"{i}&"], Splitter.SplitByNothing(), null, null, ExtraValues.Error))"

View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @siva_powerbi ,

 

I'm referencing this post to @ImkeF  the best M language super user on this forum.

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix Thanks for referring the post.

I was able to solve the issue using double quite 3 times.

"Table.Distinct(Table.FromList(#"&"""Sheet2 (2)"""&"["&#"Col Names"{i}&"], Splitter.SplitByNothing(), null, null, ExtraValues.Error))"

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.