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.
hi,
I want to calculate values based on date slicer selection.
for eg date slicer 01/02/2022 to 01/05/2022. I need to write DAX. can someone help on this?
for eg calculate(sum(x), date in slicer selection). what DAX function can be used to get this?
Solved! Go to Solution.
Thanks for reaching out to us.
If you create a relationship between the calendar table and the fact table, then when you filter the date in the slicer, the data in the fact table in visual will also be filtered. If you don't want the number of data rows in visual to be affected, please try the following method:
Sample (see sample file attached below)
(1) create a calendar table
calendar = calendar(DATE(2021,1,1),DATE(2022,12,31))
(2) create the measure below
Measure1 =
var _start=MINX(ALLSELECTED('calendar'),[Date])
var _end=MAXX(ALLSELECTED('calendar'),[Date])
var _sum= SUMX(FILTER('Table','Table'[Date]>=_start && 'Table'[Date]<=_end),[value])
return "date range:"&_start&"-"&_end&": "&_sum
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Thanks for reaching out to us.
If you create a relationship between the calendar table and the fact table, then when you filter the date in the slicer, the data in the fact table in visual will also be filtered. If you don't want the number of data rows in visual to be affected, please try the following method:
Sample (see sample file attached below)
(1) create a calendar table
calendar = calendar(DATE(2021,1,1),DATE(2022,12,31))
(2) create the measure below
Measure1 =
var _start=MINX(ALLSELECTED('calendar'),[Date])
var _end=MAXX(ALLSELECTED('calendar'),[Date])
var _sum= SUMX(FILTER('Table','Table'[Date]>=_start && 'Table'[Date]<=_end),[value])
return "date range:"&_start&"-"&_end&": "&_sum
Best Regards,
Community Support Team _Tang
If this post helps, please consider Accept it as the solution to help the other members find it more quickly.
Hi,
i think you don't need to write any dax.
You only need to create a relationship between your calendar table and your fact table.
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 | |
21 | |
21 | |
14 | |
13 |
User | Count |
---|---|
44 | |
32 | |
30 | |
18 | |
17 |