Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Senarath
Frequent Visitor

Values for Corresponding previous period and current period when using a date range

Hi Experts,

 

I'm using a date slicer with the display option "Between" so that I can select a date range. I need two columns in a single table for current period and corresponding previous period (e.g. May-17 Vs May-16). So when I select a date range which could be a week, a month, a Qtr or an year, the two columns should show values for the selected periods both current and corresponding previous.

 

I tried with functions such as DATEADD ( counts a full year), PREVIOUSYEAR (counts a full year), SAMEPERIODLASTYEAR (not working for date slicer with a renage), PARALLELPERIOD (again count full year or month ). But still my requirement is not met.

 

Any help please....

 

Thanks

Senarath

 

1 ACCEPTED SOLUTION

Hi @Senarath

 

No problem, Variables are something that is fairly new.

 

Here is a sample below, please note that I have created a Date Table to use the DateAdd Function. You can find my blog post here on how to create and map a Date table: https://www.fourmoo.com/2016/09/13/power-bi-how-to-easily-create-dynamic-date-tabledimension-with-fi...

 

Date Range Back Same Period = 
VAR MinDate = MIN('Date'[Date])
VAR MaxDate = MAX('Date'[Date])
RETURN
CALCULATE([My Measure],FILTER(ALL('Date'[Date]),DATEADD('Date'[Date],+1,YEAR) >= MinDate
	&& DATEADD('Date'[Date],+1,YEAR) <= MaxDate)
)

 

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!







Power BI Blog

View solution in original post

12 REPLIES 12

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.