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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
cgkas
Helper V
Helper V

How to add list to table in single step?

Hi all,

 

I have this code

= Table.AddColumn(
    Table.FromRecords({[A = 1],[A = 2],[A = 3],[A = 4]}), //Column "A"
    "NewData", // New column name
    each                                                                                                                                                                                                     
      let
        z =   { "b",4,7,"av" } // List to add as new column
      in  z,
    type number
  )

 

for which I'm getting this output

image.png

 

 

The output I'm looking for with a single step is like this.

image.png

 

It seems I'm near of expected output but instead of each value in list appears "List" in each row. How can I do this without helper columns?

 

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

I wish I knew a better way but here's one possible method:

let
    Source = Table.FromRecords({[A = 1],[A = 2],[A = 3],[A = 4]}),
    z = {"b",4,7,"av"},
    AddCol = Table.FromColumns(Table.ToColumns(Source) & {z}, Table.ColumnNames(Source) & {"NewData"})
in
    AddCol

View solution in original post

3 REPLIES 3
AlexisOlson
Super User
Super User

I wish I knew a better way but here's one possible method:

let
    Source = Table.FromRecords({[A = 1],[A = 2],[A = 3],[A = 4]}),
    z = {"b",4,7,"av"},
    AddCol = Table.FromColumns(Table.ToColumns(Source) & {z}, Table.ColumnNames(Source) & {"NewData"})
in
    AddCol
ppm1
Solution Sage
Solution Sage

Here's 3 ways to do it:

 

1. The simplest way would just to use the Enter Data button and enter those values manually.

2. This article describes one way to do it with M code.

 

Chris Webb's BI Blog: Creating Tables In Power BI/Power Query M Code Using #table() Chris Webb's BI ...

 

= #table(type table [A = Text.Type, NewData = Text.Type], {{1,"b"}, {2,4},{3,7},{4,"av"}})

 

3. Use Table.FromColumns

 

let
    Source = Table.FromRecords({[A = 1],[A = 2],[A = 3],[A = 4]}),
    Output = Table.FromColumns(Table.ToColumns(Source) & {{"b",4,7,"av"}})
in
    Output

 

Pat

Microsoft Employee

@ppm1   @AlexisOlson Thanks both for your help, your solutions are almost the same and works pretty fine. I was trying to know if within the command "Table.AddColumn(...)" is possible to do the same, since this command allows features like use "each" inside of it. If not, I'll use your solutions.

 

One more question.

" If the list contains only numbers, how to tell the type is Int64 during the concatenation of Source and the List? 

 

Something like

 

 

Output = Table.FromColumns(Table.ToColumns(Source) & ({{1..4}},type number))

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.