Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
NenadV
Helper III
Helper III

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?

1 REPLY 1
v-eachen-msft
Community Support
Community Support

Hi @NenadV ,

 

You could refer to this similar case:

https://community.powerbi.com/t5/Service/PBI-app-cannot-load-odata-feed-with-M-functions-in-the-URL/...

Here is a blog for more details:

https://blog.crossjoin.co.uk/2018/05/03/troubleshooting-data-refresh-performance-issues-with-odata-d...

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors