Forum Discussion
AI14
3 years agoHelper III
Dynamically Change date range of web source (api link)
Im new to powerquery and have made a connection to a site using APi key. im trying to avoid going into the source every day to look at yesterdays data or any previous day. how can i do this dynamic...
- 3 years ago
AI14You need to include to and from in double quotes .... & "from=" & DateParameter & "to=" & DateParameter & ....
AntrikshSharma
3 years agoCommunity Champion
AI14 Are you using Excel for this? Then you can create a new query from a particular cell and then reference that query in the above code.
AI14
3 years agoHelper III
yes i am, sorry i didnt mention it.
- AntrikshSharma3 years agoCommunity Champion
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.
- AI143 years agoHelper III
ammazing and would this work for both from & to dates?
- AntrikshSharma3 years agoCommunity Champion
AI14 Did you try it?