Forum Discussion
zantarel
Helper I
1 year agoError 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 ta...
- 1 year ago
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 repTableObviously 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 repTablePete
BA_Pete
Super User
1 year agoHi 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