Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi all,
Thank you in advance. I am trying to achevie below functonality.
I have a slicer like below
Based on start date and enddate, days difference it needs to return previous start date and end date.
Slicer Selected date | O/p required | Format | ||||
mm/dd/yyyy | ||||||
Start Date | End Date | difference | Start Date | End Date | ||
Case 1 | 1/1/2022 | 1/1/2022 | 0 days | 12/31/2021 | 12/31/2021 | |
Case 2 | 2/1/2022 | 2/28/2022 | 28 Days | 1/3/2022 | 1/31/2022 | |
Case 3 | 1/1/2022 | 1/15/2022 | 15 days | 1/16/2021 | 1/31/2021 |
Solved! Go to Solution.
@Anonymous , The second set of dates is what you need
same period based on date range
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day) //add +1 if needed
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
@Anonymous , The second set of dates is what you need
same period based on date range
Last Period =
var _max =maxx(allseleceted(date),date[date])
var _min =maxx(allseleceted(date),date[date])
var datediff1 = datediff(_min,_max,day) //add +1 if needed
var _maxX = _max-datediff1
var _minX = _min -datediff1
return
CALCULATE(SUM(Sales[Sales Amount]),filter(all(date,date[date]<=_maxX &&date[date]>=_minX)))
Case 1 & Case 3 are working with above logic.
Can you please look into case 2?
User | Count |
---|---|
97 | |
77 | |
77 | |
47 | |
26 |