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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Stuquan
Frequent Visitor

Dynamic column changes handler

Hi all,

 

I have a specific problem around columns appearing/disppearing as my data refreshes daily. The source is from an API that pulls through all data for that day (I am unable to see what it will pull for that day until it has done so), somedays I might have 67 columns, the next 88 and vice versa. The error I get when I try to refresh in Power BI Service is that 'column 'X' does not exist in the rowset' and therefore it cannot refresh.

 

I am wondering if anyone knows a way of dynamically handling column changes e.g. being added/removed say in the advanced editor? I have tried to create a null table with known columns that are creating errors, but each day I get a new one so this is a very static approach and extremely manual. 

 

Many thanks.

1 ACCEPTED SOLUTION

@Stuquan,

 

Right, that's why I was thinking of dynamically getting a column count each day. You would essentially be creating dynamic M that adjusts to the number of columns available on any given day.

 

I did some research and found the links below. The first link seems like the simplest approach, which is to merge all columns using a delimiter, and then split the column by that delimiter.

 

https://www.youtube.com/watch?v=dYXVTAIOcw0 

 

https://community.powerbi.com/t5/Power-Query/Split-varying-number-of-columns-into-4-columns-each/m-p... 

 

The example below uses the parameter MissingField.Ignore. I guess you could list the maximum number of columns you might have, and then this parameter would cause any non-existent columns to be ignored.

 

https://www.mrexcel.com/board/threads/powerquery-pdf-file-with-varying-number-of-columns.1218981/ 





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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
Thennarasu_R
Responsive Resident
Responsive Resident

Try Selectedvalue Functions

Thanks,
Thennarasu

DataInsights
Super User
Super User

@Stuquan,

 

You can use the following M expression to refer to columns by position (0 is the first column):

 

Table.ColumnNames(PreviousStep){0}

 

One approach would be to get a column count and loop through each column, incrementing the number in curly braces. Example: iteration 1: {0}, iteration 2: {1}, until you reach the end.





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

Proud to be a Super User!




Hi @DataInsights, thanks for this insight! The main issue with this is that I do not know all the columns that exist currently, the API connector I'm using seems to be very limited in that it will only return data (daily) for that day, the next day will then have more or less different columns and when that change happens it then fails.

@Stuquan,

 

Right, that's why I was thinking of dynamically getting a column count each day. You would essentially be creating dynamic M that adjusts to the number of columns available on any given day.

 

I did some research and found the links below. The first link seems like the simplest approach, which is to merge all columns using a delimiter, and then split the column by that delimiter.

 

https://www.youtube.com/watch?v=dYXVTAIOcw0 

 

https://community.powerbi.com/t5/Power-Query/Split-varying-number-of-columns-into-4-columns-each/m-p... 

 

The example below uses the parameter MissingField.Ignore. I guess you could list the maximum number of columns you might have, and then this parameter would cause any non-existent columns to be ignored.

 

https://www.mrexcel.com/board/threads/powerquery-pdf-file-with-varying-number-of-columns.1218981/ 





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

Proud to be a Super User!




Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.