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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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