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
Psyklone
New Member

Relative WTD MTD & YTD values

Hi,

 

Our business does some pretty standard Last week, MTD, and YTD reporting of sales etc.

There are plenty of ways to show this information, however how would I do it AND allow the user to pick which week/day this reporting up to.

 

For instance, lets say weve just finished week 9. So last week will be Week 9, MTD would be weeks 6-9 (give or take), and YTD would be weeks 1-9 (of the chosen year).

I can set up a report to show this data, but once we advance past week 10 how can I allow the user to see week 9's version of the report again? If I use a slicer and they pick week 9, then MTD and YTD won't work as it won't sum all the relevant records, only those with a week equal to 9.

 

Do I structure my data differently, or can I make a slicer linked to just one set of information?

Would I need to create measures to calculate if a sales record was part of the MTD and YTD data? And how would I reference the slicer selection to calculate this?

I feel like I'm missing something obvious.

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Psyklone,

 

You can refer to below formulas if it suitable for your requirement:


MTD and YTD measure formulas:

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

YTD = CALCULATE(SUM('Fact'[Amount]),DATESYTD('Calendar'[Date]))

 

For week number to date, you can create a new table to store these week numbers, then use it as the source of slicer, and write measures based on it.(notice: please don't build relationship between this table to another tables)

 

Week number table:

Table = SELECTCOLUMNS('Calendar',"Week",WEEKNUM('Calendar'[Date],1)) 

 

WTD measure:

WTD = 
var current_date=MAX('Fact'[Date])
var selected = if(HASONEVALUE('Table'[Week]),VALUES('Table'[Week]),BLANK())
return
CALCULATE(SUM('Fact'[Amount]),YEAR('Fact'[Date])=YEAR(current_date),WEEKNUM('Calendar'[Date],1)<selected)

1.PNG

 

Notice: if you want the week slicer also works on mtd and ytd, you can add the weeknum filter to above formulas.

var selected = if(HASONEVALUE('Table'[Week]),VALUES('Table'[Week]),BLANK())

WEEKNUM('Calendar'[Date],1)<selected)

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

1 REPLY 1
v-shex-msft
Community Support
Community Support

Hi @Psyklone,

 

You can refer to below formulas if it suitable for your requirement:


MTD and YTD measure formulas:

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

YTD = CALCULATE(SUM('Fact'[Amount]),DATESYTD('Calendar'[Date]))

 

For week number to date, you can create a new table to store these week numbers, then use it as the source of slicer, and write measures based on it.(notice: please don't build relationship between this table to another tables)

 

Week number table:

Table = SELECTCOLUMNS('Calendar',"Week",WEEKNUM('Calendar'[Date],1)) 

 

WTD measure:

WTD = 
var current_date=MAX('Fact'[Date])
var selected = if(HASONEVALUE('Table'[Week]),VALUES('Table'[Week]),BLANK())
return
CALCULATE(SUM('Fact'[Amount]),YEAR('Fact'[Date])=YEAR(current_date),WEEKNUM('Calendar'[Date],1)<selected)

1.PNG

 

Notice: if you want the week slicer also works on mtd and ytd, you can add the weeknum filter to above formulas.

var selected = if(HASONEVALUE('Table'[Week]),VALUES('Table'[Week]),BLANK())

WEEKNUM('Calendar'[Date],1)<selected)

 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

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.