Search code examples
powerbiodatapowerquery

Power Query & Odata.Feed "How can i add a Parameter to source query?"


I am creating a Power Query connection via Odata.Feed and i need to insert a parameter (DateTimeZone.LocalNow).

OData.Feed("https://test.test?$filter=Test eq '1969' and WhseTaskConfWhseTmznDate  ge datetime'2023-06-28T10:20:00'&$select=Activity", null, [Implementation="2.0"])

I would like to include a parameter so that i just get the today's Data and not all.

Any Idea how to set the Parameter and include it to the source code?


Solution

  • How about

     x = OData.Feed("https://test.test?$filter=Test eq '1969' and WhseTaskConfWhseTmznDate ge datetime'
       "&DateTime.ToText(DateTime.LocalNow(), [Format="yyyy-MM-ddTHH:mm:ss", Culture="en-US"])&"
      '&$select=Activity", null, [Implementation="2.0"])
    

    EDIT

    to pick up a date that is not today, for example one day back

    Date.AddDays(DateTime.LocalNow(),-1)
    

    or use a variable

    Date.AddDays(DateTime.LocalNow(),VariableDays)
    

    where you define that name in an earlier step as

    VariableDays= Excel.CurrentWorkbook(){[Name="rangenamehere"]}[Content]{0}[Column1],
    

    and have set up a defined range name caleld rangenamehere in the excel file that contains a number you will pull in