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! Learn more

Reply
zantarel
Helper I
Helper I

Error Handling an empty source

Hi all 

I'm querying ARG in PowerQuery, but one of my tables is returning empty, which is breaking the rest of the query. I have added error handling and i'm just trying to basically get an empty table with the correct column names, but I am running into a problem with the empty row that I'm trying to insert... 

 

Current code: 

if Table.HasColumns(Source, "Results") then #table({"id", "name", "type", "tenantId", "kind", "location", "resourceGroup", "subscriptionId", "managedBy", "sku", "plan", "properties", "tags", "identity", "zones", "extendedLocation"}, {null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null}) else Source

 

This is the code and the error - whatever I put into that first row it returns this error.... 

 

zantarel_0-1758798201222.png

 

 

Would really appreciate the help!! Thanks in advance!

 

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @zantarel ,

 

Not 100% sure what you mean by "one of my tables is returning empty" as there's a couple of ways to interpret this, but I'm assuming it's just completely void i.e. no columns or anything. If so, try something along these lines:

let
    Source = #table(1, {{1}}),
    remCol = Table.RemoveColumns(Source,{"Column1"}),
    // Error handling from here ===>
    buildAltTable = #table({"id", "name", "type", "tenantId", "kind", "location", "resourceGroup", "subscriptionId", "managedBy", "sku", "plan", "properties", "tags", "identity", "zones", "extendedLocation"}, {}),
    repTable = if List.Count(Table.ColumnNames(remCol)) = 0 then buildAltTable else remCol
in
    repTable

 

Obviously this can be condensed into a single step, if you prefer, something like this:

let
    Source = #table(1, {{1}}),
    remCol = Table.RemoveColumns(Source,{"Column1"}),
    // Error handling from here ===>
    repTable = if List.Count(Table.ColumnNames(remCol)) = 0
        then #table({"id", "name", "type", "tenantId", "kind", "location", "resourceGroup", "subscriptionId", "managedBy", "sku", "plan", "properties", "tags", "identity", "zones", "extendedLocation"}, {})
        else remCol
in
    repTable

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
zantarel
Helper I
Helper I

Thank you! That fixed it for me!! Appreciate the help!

 

No problem, happy help 🙂👍

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




BA_Pete
Super User
Super User

Hi @zantarel ,

 

Not 100% sure what you mean by "one of my tables is returning empty" as there's a couple of ways to interpret this, but I'm assuming it's just completely void i.e. no columns or anything. If so, try something along these lines:

let
    Source = #table(1, {{1}}),
    remCol = Table.RemoveColumns(Source,{"Column1"}),
    // Error handling from here ===>
    buildAltTable = #table({"id", "name", "type", "tenantId", "kind", "location", "resourceGroup", "subscriptionId", "managedBy", "sku", "plan", "properties", "tags", "identity", "zones", "extendedLocation"}, {}),
    repTable = if List.Count(Table.ColumnNames(remCol)) = 0 then buildAltTable else remCol
in
    repTable

 

Obviously this can be condensed into a single step, if you prefer, something like this:

let
    Source = #table(1, {{1}}),
    remCol = Table.RemoveColumns(Source,{"Column1"}),
    // Error handling from here ===>
    repTable = if List.Count(Table.ColumnNames(remCol)) = 0
        then #table({"id", "name", "type", "tenantId", "kind", "location", "resourceGroup", "subscriptionId", "managedBy", "sku", "plan", "properties", "tags", "identity", "zones", "extendedLocation"}, {})
        else remCol
in
    repTable

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
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!

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.

Top Kudoed Authors
Users online (11,381)