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
bideveloper555
Helper IV
Helper IV

YOY & MOM for specific year with slicer.

hi,

this is my YOY measure for current year - 3 which is 2019.

but if we go into 2022, i still want to show 2019 .

TurnoverYo3Y =
        CALCULATE(
            SUM('tablename'[Amount]),
            DATEADD('Date'[Date].[Date], -3, YEAR)
 
        )
 
how do i replace with static value as 2019.
 Same for 3 MOM% 3 year back vs current but again 3 years back will 2019 always.
 

Amt 3Y 3 MoM% =

VAR __PREV_MONTH =
CALCULATE(
SUM('Tablename'[Amt]),DATESINPERIOD('Date'[Date],ENDOFMONTH(dateadd('Date'[Date],-36,MONTH)),-3,MONTH)

)

var __CURRENTMONTH = CALCULATE(SUM('Tablename'[Amt]),DATESINPERIOD('Date'[Date],ENDOFMONTH('Date'[Date]),-3,MONTH))
Var _SalesYOY = IF (
NOT ISBLANK ( __CURRENTMONTH )
&& NOT ISBLANK ( __PREV_MONTH ),
__CURRENTMONTH - __PREV_MONTH
)


RETURN
DIVIDE(
_SalesYOY,
__PREV_MONTH
)


)

2 REPLIES 2
bideveloper555
Helper IV
Helper IV

thank you amit for your quick feed back.

power bi model as date table and every thing work fine for yoy and yoy last 2yrs or 3 yrs.

but i want to have yoy , current user selection vs 2019 always.

if user select from date slicer jan 2021, i need to show jan 2019 yoy.

if user selects jan 2020, i need to show jan 2020 vs jan 2019

if user select feb 2021,than feb 2021 vs feb 2019.

2019 will be static year

as going forward, ser selects jan 2022, than yoy should be jan 2019 vs jan 2022.

 

I did read the medium article but there is no information about static year selection with dynamic month change.

2019 WILL BE STATIC YEAR.

 sorry to be pain.

 

 

@amitchandak 

amitchandak
Super User
Super User

@bideveloper555 ,Mark date table as date table , option on right click. do not use .date in time intelligence

 

This should work with any period , mean if you group by month this will give month data

 

CALCULATE(
SUM('tablename'[Amount]),
DATEADD('Date'[Date], -3, YEAR)

)

 

Only Month or MTD

CALCULATE(
SUM('tablename'[Amount]),
datesmtd(DATEADD('Date'[Date]., -3, YEAR) )

)

 

for YOY or YTD 3 year back

 

YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD('Date'[Date],"12/31"))
Last YTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(dateadd('Date'[Date],-3,Year),"12/31"))
This year= CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR('Date'[Date]),"12/31"))
Last year= CALCULATE(SUM(Sales[Sales Amount]),DATESYTD(ENDOFYEAR(dateadd('Date'[Date],-3,Year)),"12/31"))

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

 

 

example

Power BI — Year on Year with or Without Time Intelligence
https://medium.com/@amitchandak.1978/power-bi-ytd-questions-time-intelligence-1-5-e3174b39f38a
https://www.youtube.com/watch?v=km41KfM_0uA

diff = [This Year]-[Last Year ]
diff % = divide([This Year]-[Last Year ],[Last Year ])

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.