How to exit query if URL is empty

Posts: 1
Joined: Mon Apr 15, 2019 7:39 am

How to exit query if URL is empty

Postby dsurber » Mon Apr 15, 2019 7:54 am

So we have a gaming community of a few thousand people who all play the same game. The game can be played via Facebook and that's what we use to gather tournament player information and scores. On different tournaments, there are a different number of levels in play. We load all of the URLs into a table in the workbook and have queries that go load the data. We refresh the data every 30 minutes. Right now in order to avoid errors, we modify the query properties of the levels not in play so they do not attempt to run the query on "refresh all". I just have to believe that there has to be a way to check if the field holding the URL is empty, it can just exit and avoid the error from happening this way. Here is a sample of one of the queries:

Main_Lvl_1 = Excel.CurrentWorkbook(){[Name="ABF_URLs"]}[Content]{0}[Data URL],
Source = Json.Document(Web.Contents(Main_Lvl_1)),
d = Source[d],
scores = d[scores],
#"Converted to Table" = Table.FromList(scores, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"uid", "n", "l", "p", "r"}, {"User ID", "First Name", "Last Name", "Score", "Rank"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each not Text.StartsWith([User ID], "-"))
#"Filtered Rows"

The query works just fine as is but maybe after Main_Lvl_1 is set on line 2, I would want to do something like:

If Main_Lvl_1 = "" then exit

Obviously not correct syntax but that would be the logical idea. Any ideas or help is greatly appreciated.

Posts: 219
Joined: Tue Sep 09, 2014 8:13 am

Re: How to exit query if URL is empty

Postby PhilC » Mon Apr 15, 2019 10:47 pm

Return to “Power Query”

Who is online

Users browsing this forum: No registered users and 1 guest