Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
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
Hi,
I succeeded working around the issue by filtering AzureStorage.Blobs result and checking its emptyness or not.
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"
User | Count |
---|---|
128 | |
108 | |
100 | |
65 | |
62 |
User | Count |
---|---|
137 | |
115 | |
102 | |
71 | |
61 |