Forum Discussion
Anonymous
7 years agoNot applicable
Get data from Web with date in the link
Hello, My company uses service that outputs data (KPIs) via web requests, which include list of required KPIs, line numbers and required date. I can easily transform output data into proper table...
- Anonymous7 years ago
This is possible. But I need more inputs. Will you be able to do the following...
- Connect your PowerBI desktop file to the web by using a static URL for the current day and import the data to a table.
- Then copy the PowerQuery/M Query from the Advanced Query Editor in EditQueries window and post the automatically generated power query script here.
Once you post the query here, I will be able to modify it to automatically change the CurrentDate, Day-1, and Day-2 and post the modified query back to you.
But the approach is as follows...
- We will have to nest three let-in statements that generate a table for each date inside an outer let-in statement
- Then combine the 3 tables generated using the nested let-in statements into a single table using Table.Combine() function and return this as a result of the let-in statement at outer level.
- Identify the URL used for each date and modify the URL to automatically change the dates daily by using the following Power Query functions.
- DateTime.LocalNow() // this will get the current system date in DateTime format.
- DateTime.Date() // Pass the DateTime value into this to convert the DateTime value to Date value.
- Date.ToText() //Pass the date value to this function to convert it as a string. This will accept only Date value. So we will have to convert the DateTime from Step1 into Date in Step2
- Store the URL's prefix and suffix into variables. Let us call them URLPrefix and URLSuffix.
- Form the required URL by combining the URLPrefix, <Date>, URLSuffix where the <Date> will be the output string of Date.ToText() function.
- To combine the strings, use the function Text.Combine().
- Now modify the power query that is generated automatically by replacing the URL in the power query script with the URL you have derived at Step 6.
- The steps 1 to 7 will have to be repeated for each let-in statement for Day, Day-1, and Day-2.
- Then combine these 3 let-in statement's output tables into a single one using Table.Combine() and return the same as the result of the outer let-in statement.
oumeshD
3 years agoNew Member
Hi,
Can someone help in the below formula.
https://igateway.co.za/reports/451d723ec0etgjujbb11c3ad0dec22fb67/AllPolicies_2023-01-16.xlsx
I just want to modify this url so that the date change automatically to to Today's date and in the same date format.
Please help
Anonymous
3 years agoNot applicable
Try adding these to your PowerQuery that fetches the data:
// Get the current date in the format 'YYYY-MM-DD'
currentDate = Text.From(DateTime.LocalNow(), "yyyy-MM-dd"),
// Base URL without the date part
baseUrl = "https://igateway.co.za/reports/451d723ec0etgjujbb11c3ad0dec22fb67/AllPolicies_",
// Construct the complete URL with the current date
completeUrl = baseUrl & currentDate & ".xlsx"