Forum Discussion

EC305's avatar
EC305
New Member
1 year ago
Solved

Handling Missing Columns in Combined Files to Maintain Header Alignment

When combining six files for example, sometimes one or a few of the files will have one column (titled "YYY") with no data which causes the column to not report in that file and headers to shift. Exa...
  • rohit1991's avatar
    1 year ago

    In Power BI, you can use Power Query to handle this issue:

    1. Load Data: Load your combined file into Power Query.
    2. Identify Misalignment:
      • Add a conditional column: = if Text.EndsWith([Col. A], "1.txt") and [Col. M] <> "YYY" then true else false.
    3. Shift Columns:
      • Duplicate your table.
      • Shift columns M-W for misaligned rows using a custom column and transformation logic.
    4. Combine Data:
      • Append the corrected table back to the original, ensuring all rows align.