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
Anonymous
Not applicable

Year to Date over Same Period Percentage of Change

From Google Analytics data I want to show the number of pageviews for the year to date and show the percentage of change over the same period last year. So, for the current year I want to show total number of pageviews 1/1/2016-[current date] and the percentage change from the same period in 2015, 1/1/2015-[current date].

 

I've used three measures to try  and calculate this:

 

PageviewsYTD = TOTALYTD(SUM(Fact[Pageviews]),DimDate[Date],All('DimDate'),"12/31")

 

Pageviews_PreYear = CALCULATE( SUM( Fact[Pageviews] ), PREVIOUSYEAR('DimDate'[Date]))

 

Pageviews_YoY%Change = DIVIDE([PageviewsYTD] -[Pageviews_PreYear],[Pageviews_PreYear])

 

I have also used a slicer on the page for years.

 

The measures work when there are whole years of data e.g. 2015-2014 or 2014-2013, but when the slicer is on the current year the percentage of change is not accurate because its comparing YTD 2016 to all of 2015.

 

Questions:

What measures are needed to get an accurate YTD 2016 compared to the same YTD period of the previous year?

Can I still use a slicer so the report page can include data for 2013-2016?

 

Thanks in advance,

Jeff

 

 

1 ACCEPTED SOLUTION
v-ljerr-msft
Employee
Employee

@Anonymous

 

According to your description, your second measure Pageviews_PreYear should calculate LY YTD instead of the whole last year. So the formula below is for your reference. And you should be able to use the slicer in the report. 

Pageviews_LY_YTD =
CALCULATE ( [PageviewsYTD], SAMEPERIODLASTYEAR ( 'DimDate'[Date] ) )

Following is the result of my sample data for your reference.

d1.PNGr2.PNG

Regards

View solution in original post

3 REPLIES 3
v-ljerr-msft
Employee
Employee

@Anonymous

 

According to your description, your second measure Pageviews_PreYear should calculate LY YTD instead of the whole last year. So the formula below is for your reference. And you should be able to use the slicer in the report. 

Pageviews_LY_YTD =
CALCULATE ( [PageviewsYTD], SAMEPERIODLASTYEAR ( 'DimDate'[Date] ) )

Following is the result of my sample data for your reference.

d1.PNGr2.PNG

Regards

Anonymous
Not applicable

Thanks, Jerry. That worked.

 

Can you offer some direction on how to do the same thing with a Month Over Month calculation?

 

I have previously done MoM with two measures:

Pageviews_PreMonth =

CALCULATE( SUM( FactSCRAMAnalytics[Pageviews] ), PREVIOUSMONTH( 'DimDate'[Date]) )

 

Pageviews_Monthly%Change =
VAR Pageviews_CurrentMonth =
CALCULATE ( SUM (FactSCRAMAnalytics[Pageviews] ) )
RETURN
(
IF (
NOT ( ISBLANK ( [Pageviews_PreMonth] ) ),
DIVIDE (Pageviews_CurrentMonth - [Pageviews_PreMonth], [Pageviews_PreMonth] )
)
)

 

But I'm not sure this is calculation the MoM percenatge correctly when the month is less the complete, e.g. comparing 9/1-9/19 to 8/1-8/19.

Jeff

@Anonymous

 

The formulas below are for your reference.

Pageviews_MTD =
TOTALMTD ( SUM ( Fact[Pageviews] ), DimDate[Date], ALL ( 'DimDate' ) )

Pageviews_LM_MTD =
CALCULATE ( [Pageviews_MTD], DATEADD ( 'DimDate'[Date], -1, MONTH ) )

Regards

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.