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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
bashairmu
New Member

The column of the table was not found

I’m working on extracting columns from multiple PDFs using Power Query (Combine and Transform). However, one of the columns is missing from some of the PDFs, which causes the loading process to fail. Is there a function that can enforce a null value when a column doesn’t exist?

IMG_0020.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @bashairmu 

I am glad to help you.

 

Perhaps you can refer to my M code:

let
    PDF1 = Table.FromRecords({
        [Company Name="ABC Corp", Company ID=12345, Revenue=100000],
        [Company Name="XYZ Ltd", Company ID=67890, Revenue=150000]
    }),
    PDF2 = Table.FromRecords({
        [Company Name="DEF Inc", Revenue=200000],
        [Company Name="GHI LLC", Revenue=250000]
    }),
    PDF3 = Table.FromRecords({
        [Company Name="JKL Co", Company ID=54321, Revenue=300000],
        [Company Name="MNO Group", Company ID=98765, Revenue=350000]
    }),
    CombinedPDFs = Table.Combine({PDF1, PDF2, PDF3}),

    AddMissingCompanyIDColumn = (inputTable as table) as table =>
    let
        AddMissingColumn = if Table.HasColumns(inputTable, "Company ID") then
            inputTable
        else
            Table.AddColumn(inputTable, "Company ID", each null)
    in
        AddMissingColumn,

    Result = AddMissingCompanyIDColumn(CombinedPDFs)

in
    Result

 

Result:

vfenlingmsft_0-1730106640060.png


I have attached the pbix file for this example below, I hope it helps.

 

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi, @bashairmu 

I am glad to help you.

 

Perhaps you can refer to my M code:

let
    PDF1 = Table.FromRecords({
        [Company Name="ABC Corp", Company ID=12345, Revenue=100000],
        [Company Name="XYZ Ltd", Company ID=67890, Revenue=150000]
    }),
    PDF2 = Table.FromRecords({
        [Company Name="DEF Inc", Revenue=200000],
        [Company Name="GHI LLC", Revenue=250000]
    }),
    PDF3 = Table.FromRecords({
        [Company Name="JKL Co", Company ID=54321, Revenue=300000],
        [Company Name="MNO Group", Company ID=98765, Revenue=350000]
    }),
    CombinedPDFs = Table.Combine({PDF1, PDF2, PDF3}),

    AddMissingCompanyIDColumn = (inputTable as table) as table =>
    let
        AddMissingColumn = if Table.HasColumns(inputTable, "Company ID") then
            inputTable
        else
            Table.AddColumn(inputTable, "Company ID", each null)
    in
        AddMissingColumn,

    Result = AddMissingCompanyIDColumn(CombinedPDFs)

in
    Result

 

Result:

vfenlingmsft_0-1730106640060.png


I have attached the pbix file for this example below, I hope it helps.

 

 

 

I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Fen Ling,
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

AsNa_92
Resolver II
Resolver II

Hi

 

You can edit your query by adding a new column and refresh again from advance editor, example:

 

let
    Source = Excel.Workbook(File.Contents("Y:\Data.xls"), null, true),
    #"Promoted Headers" = Table.PromoteHeaders(#"Detailed Report1", [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"date", Int64.Type}, {new column}})
in
    #"Changed Type"

Could you elaborate further? Knowing that I have over 100 PDFs, and some of them do not include a column named "Company ID." What I need is to check the PDF: if the "Company ID" column exists, I want to extract its value; if it doesn't exist, I would like to assign a null value.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors