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
Bobbys
Helper III
Helper III

Need help with weekly data

Hello everyone, 

 

I'm creating a dashboard which consists of weekly data. I am struggling with creating YTD and MTD measures that make sense.

The weekly data is formatted as a date for the delivery week. With this, I am easily able to create YTD and MTD measures. However, the issue occurs when I try to create measures for last years YTD and MTD. 


Due to it being weekly data, my MTD-1 (MTD last year) measure will be wrong. Sometimes, the month consists of 5 delivery dates (i.e. April 2nd, April 9th, April 16th, April 23th and April 30th. If april last year only consisted of 4 delivery dates, it would show that MTD for April is much higher than MTD-1, due to it consisting of an extra delivery week. 
The same goes for my YTD measure. My YTD change may be inflated due to there being an extra delivery date this year compared to last year. 

 

Does anyone have any tips to fix this issue? Is there a way I can compare week number with week number? I.e. make my YTD/MTD and YTD-1/MTD-1 measures compare year number 2022 20 with 2021 20= Or, is there any way to make my YTD/MTD measures calculate based not on the last date this year, but last date last year? 

 

I'm kind of lost and really have no idea how to solve this, but I reckon weekly data is normal and many people have faced this issue before? 


Thanks in advance

 

2 REPLIES 2
amitchandak
Super User
Super User

@Bobbys , MTD is a little bit tricky, for YTD we can use weekly YTD

 

example

 

YTD= CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year]) && 'Date'[Week] <= Max('Date'[Week]) ))
LYTD = CALCULATE(sum('Table'[Qty]), FILTER(ALL('Date'),'Date'[Year]=max('Date'[Year])-1 && 'Date'[Week] <= Max('Date'[Week])))

 

for MTD you need to assign a date every week, post distribute or consider fill week in a month

 

Week to Year =

var _sty = date([Year],1,1)

var _styw = _sty  -weeknum(_sty ,2) +1

return

_sty  + [Week] *7

 

 

Post that using the date table

 

MTD Sales = CALCULATE(SUM(Sales[Sales Amount]),DATESMTD('Date'[Date]))

Hello @amitchandak,
It seems that the YTD-1 works well! Thank you very much. However, I only get the correct YTD-1 when I filter for year. Unless I filter for 2022 it shows a much higher number. Any idea what might cause this? 

Bobbys_0-1652689934944.png

 

 

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.