Forum Discussion

NenadV's avatar
NenadV
Helper III
6 years ago

Is it possible to pass variable to OData query filter?

So I want to filter data that is coming from OData feed by date, I want to pull just rows where date column value is in last 7 days. I create variable:

SevenDaysAgo = Date.AddDays(DateTime.LocalNow(),-7),
year = Number.ToText(Date.Year(SevenDaysAgo)),
month = if Date.Month(SevenDaysAgo)<10 then Text.Combine({"0",Number.ToText(Date.Month(SevenDaysAgo))}) else Number.ToText(Date.Month(SevenDaysAgo)),
day = if Date.Day(SevenDaysAgo)<10 then Text.Combine({"0",Number.ToText(Date.Day(SevenDaysAgo))}) else Number.ToText(Date.Day(SevenDaysAgo)),
dateText = Text.Combine({year,"-",month,"-",day,"Z"})

 

and then I am using this variable dateText in my  OData query:

Source = OData.Feed("https://analytics.dev.azure.com/myOrgName/_odata/v3.0-preview/WorkItems?
$filter=Project/ProjectName eq 'ProjName' 
&$select=SomeColumns
&$apply=filter((WorkItemType eq 'Bug' or WorkItemType eq 'Task')and Iteration/EndDate ge "& dateText &")&$expand=Iteration($select=IterationName,EndDate,Depth,StartDate))")

 

This works fine in Power BI Desktop, but when I publish report to PBI Service, I get error message "Query contains unsupported function. Function name: OData.Feed"

I googled a lot about this topic but I did not find any solution, so I hope that somebody have some solution for this problem?