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
bo_afk
Post Patron
Post Patron

Week to date figures for last year

My data shows sales figures for each day of the current week for this year, plus the same week the previous year. Since the week is not yet finished, we have some blank fields for some days.

 

Week 46

Day20192018
Sunday         18,667         17,179
Monday         13,931           4,709
Tuesday         11,493           5,893
Wednesday         12,916           6,694
Thursday         17,703           9,619
Friday                  -             5,942
Saturday                  -             6,587

 

Is it possible to calculate a 'week-to-date' figure for the previous year, but only for the days we have data for in the current year?

 

E.g. we only have 2019 data for sunday-thursday, can we calcualte the total for sunday-thursday for 2018 as well?

 

My data model has the following columns

 

Year
Week number
Day of the week (in number, starting Sunday)
Day name of the week
Sales figure

 

Many thanks

 

afk

1 REPLY 1
v-jayw-msft
Community Support
Community Support

Hi @bo_afk ,

 

Please check following steps as below and see if the result achieve your expectation:

1. Create calculated table as slicer:

Table 2 = DISTINCT('Table'[Year])

 2. Create measures:

Measure = 
var valuesprevious = CALCULATETABLE(VALUES('Table'[Day of the week]),FILTER(ALL('Table'),'Table'[Year] = MAX('Table'[Year])+1&&'Table'[Week number] = MAX('Table'[Week number])))
return
IF(MAX('Table'[Day of the week]) in valuesprevious ,MAX('Table'[Sales figure]),"-")
Measure 2 = CALCULATE(SUMX('Table',[Measure]),FILTER('Table','Table'[Year] = SELECTEDVALUE('Table 2'[Year])-1))

Result would be shown as below:

1.PNG2.PNG

BTW, Pbix as attached, hopefully works for you.

 

Best Regards,

Jay

Community Support Team _ Jay Wang

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

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

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.