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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
2013smt
Regular Visitor

Error Handling for API that returns empty dataset

Hi,

 

When I attempt to refresh a dataset (Source[data]) that is empty and error is thrown:

Expression.Error: The column 'Column1' of the table wasn't found.
Details:
Column1

 

Below is M Query call to API.

 

let


HeaderKey = [Headers =[#"api-key"="xyz"]],
SourceUrl = "https://myapi.com/api/v1/disabledtrain",
Source = Json.Document(Web.Contents(SourceUrl,HeaderKey)),

Data = Source[data],
#"Converted to Table" = Table.FromList(Data, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Renamed Columns" = Table.RenameColumns(#"Converted to Table",{{"Column1", "DisabledTrain"}}),
#"Expanded DisabledTrain" = Table.ExpandRecordColumn(#"Renamed Columns", "DisabledTrain", {"affected", "goId", "trainId", "connectingTrnId", "trainArriveTime", "connectingTrainDepartTime", "stationId", "majorLocCd", "updatedBy", "updatedDate"}, {"DisabledTrain.affected", "DisabledTrain.goId", "DisabledTrain.trainId", "DisabledTrain.connectingTrnId", "DisabledTrain.trainArriveTime", "DisabledTrain.connectingTrainDepartTime", "DisabledTrain.stationId", "DisabledTrain.majorLocCd", "DisabledTrain.updatedBy", "DisabledTrain.updatedDate"}),
#"Renamed Columns1" = Table.RenameColumns(#"Expanded DisabledTrain",{{"DisabledTrain.affected", "Affected"}, {"DisabledTrain.connectingTrainDepartTime", "Connect Depart Time"}, {"DisabledTrain.connectingTrnId", "Connecting Train"}, {"DisabledTrain.goId", "General Order"}, {"DisabledTrain.majorLocCd", "Major Location Code"}, {"DisabledTrain.stationId", "Station"}, {"DisabledTrain.trainArriveTime", "Train Arrive Time"}, {"DisabledTrain.updatedBy", "Updated By"}, {"DisabledTrain.updatedDate", "Updated Date"}, {"DisabledTrain.trainId", "Train"}})
in
#"Renamed Columns1"

 

How can I handle this situation?

2 REPLIES 2
Anonymous
Not applicable

Hi @2013smt ,

Whether your problem has been resolved?

Best Regards

Anonymous
Not applicable

Hi @2013smt ,

Could you please confirm that whether it exist the field named "Column1" in your source? Please provide the related screenshot of source data in order to make troubleshooting. You can also refer the content in the following links to resolve your problem.

The column of the table wasn't found

Power Query: Preventing "The column of the table wasn't found" error

Best Regards

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.