Forum Discussion
mike_asplin
Helper V
1 year agoHelp using SQl to limit the data being pulled form Microsoft Dynamics by Odata
I current have a model that is pulling whole tables of data form Microsoft Dynamics anbd then doing al lthe filtering in Power query. Is therer a way to do the filtering at source like you woudl wit...
Cookistador
Super User
1 year agoHi mike_asplin
As you are using odata, it is possible to acheive that
You can find more information under the following link:
https://www.odata.org/getting-started/basic-tutorial/
But to achieve that, you can edit your power query with the following approach:
let
Url = "https://chaxxxxx.api.crm11.dynamics.com/api/data/v9.1/",
SelectColumns = "name,_cha_clientid_value,_owningteam_value,duration,starttime,_cha_carercontactid_value,_msdyn_workorder_value,msdyn_totalcost,endtime,statuscode,msdyn_milestraveled,msdyn_actualarrivaltime",
FilterDateText = DateTime.ToText(Dateparameter, "yyyy-MM-ddTTHH:mm:ssZ"),
FilterQuery = "$filter=starttime ge " & FilterDateText,
ODataQueryOptions = [
Query = "$select=" & SelectColumns & "&$" & FilterQuery
],
Source = OData.Feed(Url, null, [Implementation="2.0"]),
bookableresourcebookings_table = Source{[Name="bookableresourcebookings", Signature="table"]}[Data],
Data = OData.Feed(bookableresourcebookings_table, null, ODataQueryOptions)
in
Data
Just to be sure to call the date Parameter to Dateparameter and replace the url by the right url and it should work
mike_asplin
Helper V
1 year agoSeems ot be taking for ever. Can I check there arent any typoes
Whats the ge for?
FilterQuery = "$filter=starttime ge " & FilterDateText,
Why is time surrounded by TT and Z?
FilterDateText = DateTime.ToText(Dateparameter, "yyyy-MM-ddTTHH:mm:ssZ"),
Thanks