Forum Discussion
Dynamically Change date range of web source (api link)
- 3 years ago
AI14You need to include to and from in double quotes .... & "from=" & DateParameter & "to=" & DateParameter & ....
AI14 Create a table in Excel with name DateParameter
And then you can load the table into PQ, the code will look like this:
let
Source =
Excel.CurrentWorkbook(){[ Name = "DateParameter" ]}[Content],
ChangedType =
Table.TransformColumnTypes ( Source, { { "Date", type datetime } } ),
Date =
Date.ToText (
Date.From ( ChangedType[Date]{0} ),
[ Format = "yyyy-MM-dd", Culture = "en-US" ]
)
in
DateAs you can see the the data type of quer is just scalar text value now you can use the name DateParameter in your original code.
ammazing and would this work for both from & to dates?
- AntrikshSharma3 years agoCommunity Champion
AI14 Did you try it?
- AI143 years agoHelper III
Date Parameter works but how do i incoporate it in code.
i tried to put it in like below and i tried how i usually had it "from=dateparameter&" etc.
none worked so far
= Json.Document(Web.Contents("https://www.findmyshift.co.uk/api/1.4/reports/hours?" & "apiKey=xxxxxx&" & "teamId=y22t0l5t4i&" & DateParameter & DateParameter & "timesheetData=yes&" & "additional-columns=staff.jobtitle&" & "additional-columns=staff.department"))
- AntrikshSharma3 years agoCommunity Champion
AI14 You are missing "from" and "to" in your code! Check your question.