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!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Hi All,
I have a set of data with corresponding dates, and a slicer to filter the data based on the selected date range.
I am trying to create a second table that looks at the input of the slicer, but presents the data in the previous equivalent period.
For example, the slicer would present the data range 01/07/2019 - 31/12/2019 (6 month period). I want one table to present the data from this range and another table that would look at the range 01/01/2019 - 01/07/2019. (i.e. previous 6 month period.)
How can I do this? I have looked at time intelligence functions but can only set intervals of fixed periods (months, days, years etc..)
Thank you
Solved! Go to Solution.
HI @Anonymous,
I'd like to suggest you take a look at below blog to know how to use DATE function to manually define filter range and do rolling calculations:
Time Intelligence "The Hard Way" (TITHW)
Regards,
Xiaoxin Sheng
HI @Anonymous,
I'd like to suggest you take a look at below blog to know how to use DATE function to manually define filter range and do rolling calculations:
Time Intelligence "The Hard Way" (TITHW)
Regards,
Xiaoxin Sheng
Please find the logic. Added logic to adjust the end of the month. if needed you can remove that. 30Th Jun will give 30jan or 30th march not 31st so done the coding for that.
Same Month range last period =
var _diff = datediff(MIN('Date'[date]),max('Date'[date]),MONTH)
var _p_st_date = MINX('Date',DATEADD('Date'[date],-1*_diff,MONTH))
var _maxDt =maxx('Date','Date'[date])
var _maxEndDt =maxx('Date',ENDOFMONTH('Date'[date]))
var _p_end_date = if(_maxDt<>_maxEndDt, MAXX('Date',DATEADD('Date'[date],-1*_diff,MONTH)),MAXX('Date',ENDOFMONTH(DATEADD('Date'[date],-1*_diff,MONTH))))
Return
//_p_st_date & " " & _p_end_date & " " &_maxDt &" " &_maxEndDt
CALCULATE(sum(Sales[Sales Amount]),all('Date'[date]),'Date'[date]>=_p_st_date && 'Date'[date]<= _p_end_date)
If you need only days
Same Date range last period =
var _diff = datediff(MIN('Date'[date]),max('Date'[date]),DAY)
var _p_st_date = MINX('Date',DATEADD('Date'[date],-1*_diff,Day))-1
var _p_end_date = MAXX('Date',DATEADD('Date'[date],-1*_diff,Day))-1
Return
CALCULATE(sum(Sales[Sales Amount]),all('Date'[date]),'Date'[date]>=_p_st_date && 'Date'[date]<= _p_end_date
)
The assumption is that you have a date range slicer (or month) and you are using date table.
To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 57 | |
| 43 | |
| 41 | |
| 22 | |
| 17 |
| User | Count |
|---|---|
| 183 | |
| 114 | |
| 93 | |
| 62 | |
| 45 |