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.
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"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
105 | |
94 | |
75 | |
63 | |
62 |
User | Count |
---|---|
137 | |
105 | |
104 | |
80 | |
63 |