Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
Hi,
I have a records based on date fields and i taken a slicer for the date field
Suppose if I select date range from 01 Mar 2019 to 31 Dec 2019, I need a count of previous date range i.e., 01 Mar 2019 to 01 Mar 2000
Here I consider that my database have the records from 01 Mar 2000 to 31 Dec 2019 and data is dynamic
Thanks in advance
Solved! Go to Solution.
@Anonymous
You need
Last period =
var _min = minx(ALLSELECTED('Date'),('Date'[Date]))
Return
CALCULATE(SUM(Sales[Sales Amount]),filter(ALL('Date'),'Date'[Date]<=_min))
Perhaps:
Measure =
VAR __MinDate = MIN('Table'[Date])
RETURN
COUNTROWS(
FILTER(
ALL('Table'),
[Date] <= __MinDate
)
)
Hi @Anonymous
Try something like
Measure =
VAR __min = MIN( 'Calendar'[Date] )
RETURN
CALCULATE(
COUNTROWS( 'Calendar' ),
ALL( 'Calendar' ),
'Calendar'[Date] < __min
)
@Anonymous
What are the previous date, seems like an overlapping date. If you need year behind data , you can use with date calendar
Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))
Or you same duration last period
Last period =
var _min = minx(ALLSELECTED('Date'),('Date'[Date]))
var _max = maxx(ALLSELECTED('Date'),('Date'[Date]))
var _diff = DATEDIFF(_min,_max,DAY)+1
var _minx = _min-_diff
var _maxx = _max -_diff
Return
CALCULATE(SUM(Sales[Sales Amount]),filter(ALL('Date'),'Date'[Date]>=_minx && 'Date'[Date<=_maxx))
Hi @amitchandak ,
I tried the DAX working super But it is getting a year earlier data but I need all years data
Example : 01 Jan 2000 to 16 Mar 2020 is a range of records in dataset
and I selected a range between 01 Mar 2020 to 16 Mar 2020 then i need a records before 01 Mar 2020 (i.e., from 01 Jan 2000 to 29 Feb 2020)
Thank you Amit for the great response in a less time
Waiting for the reply
@Anonymous
You need
Last period =
var _min = minx(ALLSELECTED('Date'),('Date'[Date]))
Return
CALCULATE(SUM(Sales[Sales Amount]),filter(ALL('Date'),'Date'[Date]<=_min))
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.