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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Query last N days of a dataset with user input

Hi,

 

I currently have a huge dataset of google analytics data that I am using as a data source in power BI. Currently, I am filtering the date manually which gives this query:

 

= Table.SelectRows(#"Added Items", each [Date] >= #date(2021, 11, 22))

 

 

What I want to do is allow the user to choose the date that the data starts, which then loads the data from the correct range. However, I don't want the report to load the entire dataset as the dataset has >20,000 rows.

 

I am trying to approach this problem by using power BI parameters with a default value that isn't too long ago, and use a list of suggested values from a query that lists dates in specific intervals, e.g., 10, 20, and 30 days ago from the current date, etc. I would then filter the date column in the dataset to be on or after the specified parameter value, but I'm not sure how to go about this as I am pretty new to Power BI. 

 

Any help is greatly appreciated.

3 REPLIES 3
AllisonKennedy
Super User
Super User

@Anonymous  You're absolutely on the right track. Have you created the parameter already? Have you generated the query with the list of values? Which step do you need help on? 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Anonymous
Not applicable

@AllisonKennedy 

I'm glad to hear that I'm on the right track. I've created the parameter with a single value as a placeholder, which does work to filter the data. However, I don't know how to create this query which lists multiple dates from N days before the current date.

@Anonymous  This function Date.AddDays might help: https://docs.microsoft.com/en-us/powerquery-m/date-adddays

 

If you can provide sample files I can give more specific help... (sorry for the long delay, took a bit of time off 🙂 )


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.