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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
ksrini
Helper I
Helper I

Relative date slicer to calculate % change for same period last year

Hi All,

 

I have a relative date slicer where user can select dates by dragging the bar left to right. I have one KPI card that calculates % change based on start and end dates selected by user. I want to build another card which % change for same period last year based on the date selected by user. In this below example the 2nd card should calculate % change over 12/29/2018 - 7/1/2019 since it is same period last year. I tried datesbetween formulae but it calculates for current period but not for previous year. YTD is close to it but it doesn't change based on user selection. Any ideas ?

ksrini_0-1601465696150.png

Thanks,

Srinivas

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @ksrini ,

 

I create a simple example. Please check whether the attached file is helpful.

 

Change % = 
VAR StartDate =
    MIN ( Dates[Date] )
VAR EndDate =
    MAX ( Dates[Date] )
VAR StartValue =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Date] = StartDate )
VAR EndValue =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Date] = EndDate )
RETURN
    DIVIDE ( EndValue - StartValue, StartValue, 0 )
Change % last year = CALCULATE([Change %],SAMEPERIODLASTYEAR(Dates[Date]))

change.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @ksrini ,

 

I create a simple example. Please check whether the attached file is helpful.

 

Change % = 
VAR StartDate =
    MIN ( Dates[Date] )
VAR EndDate =
    MAX ( Dates[Date] )
VAR StartValue =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Date] = StartDate )
VAR EndValue =
    CALCULATE ( SUM ( 'Table'[Value] ), 'Table'[Date] = EndDate )
RETURN
    DIVIDE ( EndValue - StartValue, StartValue, 0 )
Change % last year = CALCULATE([Change %],SAMEPERIODLASTYEAR(Dates[Date]))

change.JPG

 

 

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Icey,

 

Thanks for the solution and for explaining it in such simple example.

 

Best regards,

Srinivas 

amitchandak
Super User
Super User

@ksrini , Create a use a date table. Use date Table for slicer too.

 

And create a measure like

Year behind Sales = CALCULATE(SUM(Sales[Sales Amount]),dateadd('Date'[Date],-1,Year))

 

The take diff with SUM(Sales[Sales Amount])

 

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

Appreciate your Kudos.

 

if this does not work.

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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