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.
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
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
41 | |
20 | |
19 | |
15 | |
15 |
User | Count |
---|---|
47 | |
28 | |
25 | |
17 | |
17 |