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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
JianliangJiang
New Member

How to catch data source error when up stream is missing

Hi Power BI experts,

 

My scenario is to get data from Azure blob, and the Azure blob may be missing for some data by design. I plan to make use of try-catch plus if to handle this. However, below query is always stuck.  Can anyone help point the correct way to 

 

Query

let
TargetDate = DateTimeZone.FromText("2019-03-19T01:30:00"),
MetricsName = "/Mock/"& DateTimeZone.ToText(TargetDate, "yyyy/MM/dd") & "/Metrics." & DateTimeZone.ToText(TargetDate, "yyyy_MM_dd") & ".tsv",
Source = AzureStorage.BlobContents("https://xxxxxxxxxxxxxx.blob.core.windows.net/yyyyyyyyyy" & MetricsName),
TestForError = try Source,
#"Imported CSV" =

if TestForError[HasError]

then #table({"Column1", "Column2" }, null)

otherwise Csv.Document(Source,[Delimiter="#(tab)", Columns=6, Encoding=1252, QuoteStyle=QuoteStyle.None]),

in
#"Imported CSV"

 

Screenshot FYI

 

Untitled.png

3 REPLIES 3
JianliangJiang
New Member

Hi,

I succeeded working around the issue by filtering AzureStorage.Blobs result and checking its emptyness or not.

d_gosbell
Super User
Super User

I have not tested this, but I think you might just need to put the try in front of the call to AzureBlogStorage.BlobContents rather than storing that in the Source variable.

 

eg.

 

let
TargetDate = DateTimeZone.FromText("2019-03-19T01:30:00"),
MetricsName = "/Mock/"& DateTimeZone.ToText(TargetDate, "yyyy/MM/dd") & "/Metrics." & DateTimeZone.ToText(TargetDate, "yyyy_MM_dd") & ".tsv",
TestForError = try AzureStorage.BlobContents("https://xxxxxxxxxxxxxx.blob.core.windows.net/yyyyyyyyyy" & MetricsName),,
#"Imported CSV" =

if TestForError[HasError]

then #table({"Column1", "Column2" }, null)

otherwise Csv.Document(Source,[Delimiter="#(tab)", Columns=6, Encoding=1252, QuoteStyle=QuoteStyle.None]),

in
#"Imported CSV"

Thanks @d_gosbell.


The approach failed with the same behavior.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.