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
Gabe_V
Helper I
Helper I

Using List.RemoveItems in Table.ExpandTableColumn results in The field already exists in the record.

Hi folks,

 

I have a problem that I haven't been able to track down an existing solution for.

I have grouped some columns and have a single resultant aggregated column (named "All"), but I need to expand only certain specific column indexes (I can't use column names because they change from month to month).

The code I have so far looks like this:

 #"Expanded All" = Table.ExpandTableColumn(
#"Grouped Rows",
"All",
List.RemoveItems(
Table.ColumnNames(#"Grouped Rows"{0}[All]),
{0, 1, 2, 3, 4, 5, 6, 8, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 40, 44}
),
List.RemoveItems(
Table.ColumnNames(#"Grouped Rows"{0}[All]),
{0, 1, 2, 3, 4, 5, 6, 8, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 40, 44}
)
)

 

However, this results in receiving this message:

Expression.Error: The field 'Project ID' already exists in the record.
Details:
Name=Project ID
Value=

 

(Note: "Project ID" is my first column. )

I have also tried the above code, but starting from 1 instead of 0, with the same result.

Does anyone have any ideas what I'm doing wrong? Thanks in advance! 🙂

1 ACCEPTED SOLUTION
wdx223_Daniel
Community Champion
Community Champion

List.RemoveItems(
Table.ColumnNames(#"Grouped Rows"{0}[All]),
List.Transform({0, 1, 2, 3, 4, 5, 6, 8, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 40, 44},each Table.ColumnNames(#"Grouped Rows"{0}[All]){_})
)

View solution in original post

2 REPLIES 2
wdx223_Daniel
Community Champion
Community Champion

List.RemoveItems(
Table.ColumnNames(#"Grouped Rows"{0}[All]),
List.Transform({0, 1, 2, 3, 4, 5, 6, 8, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35, 40, 44},each Table.ColumnNames(#"Grouped Rows"{0}[All]){_})
)

Hi @wdx223_Daniel

Your solution looks very elegant and compact. However, unfortunately when I ran your solution, I think it may not be doable for very large data sets such as mine. It has been cranking away for about 12 minutes now.
However just this morning, I came up with a less elegant solution that I got to run in about a minute:

#"Expanded All" = Table.ExpandTableColumn(
#"Grouped Rows",
"All",
List.RemoveItems(
Table.ColumnNames(#"Grouped Rows"{0}[All]),
{Table.ColumnNames(#"Grouped Rows"{0}[All]){0},
Table.ColumnNames(#"Grouped Rows"{0}[All]){1},
Table.ColumnNames(#"Grouped Rows"{0}[All]){2},
Table.ColumnNames(#"Grouped Rows"{0}[All]){3},
Table.ColumnNames(#"Grouped Rows"{0}[All]){4},
Table.ColumnNames(#"Grouped Rows"{0}[All]){5},
Table.ColumnNames(#"Grouped Rows"{0}[All]){6},
Table.ColumnNames(#"Grouped Rows"{0}[All]){8},
Table.ColumnNames(#"Grouped Rows"{0}[All]){13},
Table.ColumnNames(#"Grouped Rows"{0}[All]){15},
Table.ColumnNames(#"Grouped Rows"{0}[All]){17},
Table.ColumnNames(#"Grouped Rows"{0}[All]){19},
Table.ColumnNames(#"Grouped Rows"{0}[All]){21},
Table.ColumnNames(#"Grouped Rows"{0}[All]){23},
Table.ColumnNames(#"Grouped Rows"{0}[All]){25},
Table.ColumnNames(#"Grouped Rows"{0}[All]){27},
Table.ColumnNames(#"Grouped Rows"{0}[All]){29},
Table.ColumnNames(#"Grouped Rows"{0}[All]){31},
Table.ColumnNames(#"Grouped Rows"{0}[All]){33},
Table.ColumnNames(#"Grouped Rows"{0}[All]){35},
Table.ColumnNames(#"Grouped Rows"{0}[All]){40},
Table.ColumnNames(#"Grouped Rows"{0}[All]){44}}
),
List.RemoveItems(
Table.ColumnNames(#"Grouped Rows"{0}[All]),
{Table.ColumnNames(#"Grouped Rows"{0}[All]){0},
Table.ColumnNames(#"Grouped Rows"{0}[All]){1},
Table.ColumnNames(#"Grouped Rows"{0}[All]){2},
Table.ColumnNames(#"Grouped Rows"{0}[All]){3},
Table.ColumnNames(#"Grouped Rows"{0}[All]){4},
Table.ColumnNames(#"Grouped Rows"{0}[All]){5},
Table.ColumnNames(#"Grouped Rows"{0}[All]){6},
Table.ColumnNames(#"Grouped Rows"{0}[All]){8},
Table.ColumnNames(#"Grouped Rows"{0}[All]){13},
Table.ColumnNames(#"Grouped Rows"{0}[All]){15},
Table.ColumnNames(#"Grouped Rows"{0}[All]){17},
Table.ColumnNames(#"Grouped Rows"{0}[All]){19},
Table.ColumnNames(#"Grouped Rows"{0}[All]){21},
Table.ColumnNames(#"Grouped Rows"{0}[All]){23},
Table.ColumnNames(#"Grouped Rows"{0}[All]){25},
Table.ColumnNames(#"Grouped Rows"{0}[All]){27},
Table.ColumnNames(#"Grouped Rows"{0}[All]){29},
Table.ColumnNames(#"Grouped Rows"{0}[All]){31},
Table.ColumnNames(#"Grouped Rows"{0}[All]){33},
Table.ColumnNames(#"Grouped Rows"{0}[All]){35},
Table.ColumnNames(#"Grouped Rows"{0}[All]){40},
Table.ColumnNames(#"Grouped Rows"{0}[All]){44}}
)
)

 

Like I said, not elegant, but it appears to do the trick.

I will keep your solution in mind for smaller datasets though.

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.