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
Jmenas
Advocate III
Advocate III

Enter a query as a parameter or add it as a part of a parameter.

Hi all,

 

I am trying to create a dynamic filter in M that allows me to filter my dataset on the days that I can request.

For example I use a filter: URL/Page$filter=createdAt gt 90d_ago

But I want to use the days Year to date, "Duration.Days(DateTime.LocalNow() - Date.StartOfYear(DateTime.LocalNow()))" then I append this to the rest of the filter ends like this: $filter=createdAt gt 63d_ago

I try to set it up as a query but the default value is always "createdAt gt 63ago". 

how can I make to add 63 dynamically?

 

Best,

Jorge

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

Hi @Jmenas,

 

If I understand you correctly, you should be able to use the following query to filter the data dynamically. Smiley Happy

days = Duration.Days(DateTime.LocalNow() - Date.StartOfYear(DateTime.LocalNow())),
filters = "createdAt gt "&Text.From(days)&"ago",
URL/Page$filter = filters

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Employee
Employee

Hi @Jmenas,

 

If I understand you correctly, you should be able to use the following query to filter the data dynamically. Smiley Happy

days = Duration.Days(DateTime.LocalNow() - Date.StartOfYear(DateTime.LocalNow())),
filters = "createdAt gt "&Text.From(days)&"ago",
URL/Page$filter = filters

Regards

Hi @v-ljerr-msft,

but in case I want to inside of a parameter that will still be the case right? 

I will test it in both cases because I also want to give the user the possibility of not using the filter in some cases. 

Best,
J.

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.