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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mbarbera83
New Member

oData URL filter for last 30 days (today less 30)

Hi Everyone.

Is it possible to filter in the source URL based on a column of document date:

 

something like - = OData.Feed("https://xxxxx.co.za/OData/ODatav4/Company('XXXX')/View?$filter = Posting date gt (now()-30)

 

I want to limit the time it takes to refresh my data, but saying just give me the last 30 days.

 

can anyone help?

1 ACCEPTED SOLUTION

Since the Date.ToText returns text, you don't need to wrap it in ".  Please try this instead.

 

= OData.Feed("https://XXXX.co.za:/ODatav4/Company/ValueEntriesPage?$filter=Posting_Date gt " & Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-65), "yyyy-MM-dd") , null, [Implementation="2.0"])

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

4 REPLIES 4
V-pazhen-msft
Community Support
Community Support

@mbarbera83 
I doubt you can filter the Source URL before importing to power bi. 
Solved: OData filter pass-through - Microsoft Power BI Community

 

For your requirement, I would suggestion you to use incremental refresh to set the refresh range to last 30 days.

Incremental refresh for datasets in Power BI - Power BI | Microsoft Docs

 

 

Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

mbarbera83
New Member

Hi Pat. Thanks for the quick response.

I tried that but received : Expression.SyntaxError: Token Comma expected.

 

I have attached below my code - am I missing something?

= OData.Feed("https://XXXX.co.za:/ODatav4/Company/ValueEntriesPage?$filter=Posting_Date gt " & Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-65), "yyyy-MM-dd")") , null, [Implementation="2.0"])

Since the Date.ToText returns text, you don't need to wrap it in ".  Please try this instead.

 

= OData.Feed("https://XXXX.co.za:/ODatav4/Company/ValueEntriesPage?$filter=Posting_Date gt " & Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()),-65), "yyyy-MM-dd") , null, [Implementation="2.0"])

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


mahoneypat
Employee
Employee

You can use this expression.  Adapt the date format if you need something different.

 

 OData.Feed("https://xxxxx.co.za/OData/ODatav4/Company('XXXX')/View?$filter= Posting date gt " & Date.ToText(Date.AddDays(Date.From(DateTime.LocalNow()), -30), "yyyy-MM-dd")")

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors