Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I have a DAX function to retrieve teh date range that user has selected
I'd like to get 6/1/2022 and 7/31/2022 in my DAX function. However, I notice that with the above DAX I am getting 6/4/2022 as the minimum as the earliest data in my table for this range is dated as 6/4/2022.
Is there a way to get 6/1/2022 and 7/31/2022 or whatever user selects in that date filter?
Thanks!
Solved! Go to Solution.
Hi @varshajain ,
Here are the steps you can follow:
1. Create measure.
mindate =
var _minx=MINX(ALLSELECTED('Table'),[Date])
var _maxx=MAXX(ALLSELECTED('Table'),[Date])
return
DATE(YEAR(_minx),MONTH(_minx),1)
mindate =
var _minx=MINX(ALLSELECTED('Table'),[Date])
var _maxx=MAXX(ALLSELECTED('Table'),[Date])
return
DATE(YEAR(_minx),MONTH(_minx),1)
2. Result:
If you need pbix, please click here.
Get User selected dates in date range.pbix
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
have you found the solution, I have the same problem
Hi @varshajain ,
Here are the steps you can follow:
1. Create measure.
mindate =
var _minx=MINX(ALLSELECTED('Table'),[Date])
var _maxx=MAXX(ALLSELECTED('Table'),[Date])
return
DATE(YEAR(_minx),MONTH(_minx),1)
mindate =
var _minx=MINX(ALLSELECTED('Table'),[Date])
var _maxx=MAXX(ALLSELECTED('Table'),[Date])
return
DATE(YEAR(_minx),MONTH(_minx),1)
2. Result:
If you need pbix, please click here.
Get User selected dates in date range.pbix
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Thank You for your response. I also did something similar to solve my issue by constructing the date based on month and year
ALLSELECTED is not the right function to use in this context since there's no iteration going on in the visual. This is why it returns the whole column. It is the most complex function in whole DAX and it should be well understood before one can use it. If one doesn't, then please don't. In yur case you should put the whole table as the first argument under min/max to get what you want.
I updated my function to this
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
11 | |
10 | |
9 | |
8 |
User | Count |
---|---|
17 | |
12 | |
11 | |
11 | |
10 |