Forum Discussion
i0054524
7 years agoFrequent Visitor
Changing Source URL with current date
Hello All, I'm running into a problem I'm hoping someone can help with. I'm fairly new to PowerBI. Here is what I'm trying to do. I'm pulling data from a website using the web as a source c...
TomMartens
7 years agoSuper User
Hey,
if you create a new Blank Query in the Query Editor of Power BI and insert the following code snippet, you will receive a string that contains the current date:
let
today = DateTime.LocalNow(),
todayDay = Text.PadStart(Text.From(Date.Day(today)),2,"0"),
todayMonth = Text.PadStart(Text.From(Date.Month(today)),2,"0"),
todayYear = Text.From(Date.Year(today)),
url = Text.Combine({"data.company9.com/scripts/events.asp?month=", todayMonth, "&day=" , todayDay, "&year=", todayYear, "&stype=17&type=B"}, "")
in
url
Hopefully this is what you are looking for.
Regards,
Tom
i0054524
7 years agoFrequent Visitor
Thank you! That worked for creating a string with the current date in the format I want in the url. Now, I might be thinking about this too hard, but now that I have that string....how do I pass that string into the query so that the url gets created and the data is pulled from that url? Not sure if that makes sense or not.