We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hi All,
I am pulling data from a dynamic URL that is using a date in the string. I have managed to create the parameter to pass over the string and everything appears to work okay. The issues I have are that;
I only want to include the date of the last WEEKDAY in the file path if the refresh time is before 1600hrs on a WEEKDAY or if it is a Saturday or Sunday.
Step 1: = Table.AddColumn(#"Changed Type", "Custom", each Date.From(DateTime.LocalNow())) - 'Creates the Date/Time'
Step 2: = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type datetime}}) - 'Transforms the Date/TIme'
Step 3: = Table.AddColumn(#"Changed Type1", "Custom.1", each DateTime.ToText([Custom],"dd-MMMM-yyyy")) - 'Transforms the Date/TIme to the required text output to pass as the query parameter'
Step 4: = #"Inserted Day of Week"[Custom.1] - 'the query output parameter'
output parapeter for the URL is named NHS URL = "15-June-2020"
Formed URL = "https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2020/06/COVID-19-total-announced-de..." & #"NHS URL Date" & ".xlsx"
Any thoughts would be really appreciated......
Hi, @Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table:
Here are the codes in 'Advanced Editor'.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlSKjQUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", Int64.Type}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each DateTime.LocalNow()),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type datetime}}),
#"Inserted Day of Week" = Table.AddColumn(#"Changed Type1", "Custom.1", each if Date.DayOfWeek([Custom])=0 or Date.DayOfWeek([Custom])=6 or DateTime.Time([Custom])<=#time(16,0,0) then DateTime.ToText(Date.EndOfWeek([Custom]),"dd-MMMM-yyyy") else null),
#"Formed URL" = if #"Inserted Day of Week"=null then null else
"https://www.england.nhs.uk/statistics/wp-content/uploads/sites/2/2020/06/COVID-19-total-announced-de..."&List.First( #"Inserted Day of Week"[Custom.1])&".xlsx"
in
#"Formed URL"
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Allan,
Many thanks for your very swift response. I maybe should have explained my issue a little clearer......
If I refreshed the report yesterday before 1600hrs the URL should have defaulted to the previous business day (Friday 12-June-2020) as the endpoint data is not published over the weekend.
If I was to refresh the report this morning before 1600hrs the dynamic URL would default to the previous business day (Monday 15-June-2020) as the new data is not published until after 1600hrs.
If I was to refresh the report today after the 1600hrs rebublication time the dynmaic URL should of course look like this.
I hope this explanation makes sense?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 53 | |
| 38 | |
| 33 | |
| 17 | |
| 17 |
| User | Count |
|---|---|
| 67 | |
| 63 | |
| 38 | |
| 34 | |
| 22 |