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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
YR26
New Member

How to deal with misaligned columns that share column headers?

Currently dealing with a project that requires me to compile excel files into a power BI report. However, some of the excel files have empty columns. Rather than returning 0s, the columns are not even returned by the program we are using to pull this data. Misaligned columns in PQ.

 

How do I go about solving this?

 

All the columns have named column headers. Is there a way to append the tables when combining the data? Maybe sort the info by column header rather than column location?

 

I was playing around a bit and got my hands on all possible column header names, put them into a table, and appended the query to my Transform Sample File. It worked on just that file and kept only unique headers, but I don't feel like I made any headways.

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

don't get your problem because Table.Combine combines tables just fine using correct column names and does not care about missing columns. If you need to make sure that table goes with full list of columns to Power BI then maybe you need to create a blank table template with all the columns listed and include it into your solution?

let
    tbl_template = #table({"col_a", "col_b", "col_c"}, {}),
    tbl_bc = #table({"col_b", "col_c"}, {{1, 2}}),
    tbl_c = #table({"col_c"}, {{1}}),
    result = tbl_template & tbl_bc & tbl_c
in
    result

View solution in original post

3 REPLIES 3
v-jingzhan-msft
Community Support
Community Support

Hi @YR26 

 

@AlienSx 's method should work. Have you tried that? 

 

In addition, your idea to append the query (which has all possible column header names) to Transform Sample File query should work. It has the same logic. Where did you think it doen's work? You can add a step to append them easily. This will be applied to all files combined. 

vjingzhanmsft_0-1713772985038.png

 

Best Regards,
Jing

AlienSx
Super User
Super User

don't get your problem because Table.Combine combines tables just fine using correct column names and does not care about missing columns. If you need to make sure that table goes with full list of columns to Power BI then maybe you need to create a blank table template with all the columns listed and include it into your solution?

let
    tbl_template = #table({"col_a", "col_b", "col_c"}, {}),
    tbl_bc = #table({"col_b", "col_c"}, {{1, 2}}),
    tbl_c = #table({"col_c"}, {{1}}),
    result = tbl_template & tbl_bc & tbl_c
in
    result
lbendlin
Super User
Super User

Please read about the difference between Table.RemoveColumns and Table.SelectColumns

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors