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

Matrix table - week over week (last year vs this year)

Hello Community, 

 

I have a matrix table where the Years are the columns and Month Week and Day are in the rows.  

 

My goal is to compare each of these granularities versus the prior year, as the user drills down. 

 

My month calculation shows the correct value.     Meaning, if I am just looking at January 2020  vs   2021  (period to date), the percentage variance is correct.  

 

However, if I drill down to the week level, the percent variance gets totally out of whack, as you can see below.    I know this subject can be quite complex but I have a date table, nothing unique like a 4-4-5 calendar, and I am not trying to count only weekdays or anything.  

 

Any help is appreciated.

 

texmexdragon_0-1611783727009.png

 

1 ACCEPTED SOLUTION
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can try to create this measure to calculate the difference by samplepeoriod last year:

percent =
VAR currentyear =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( 'Table', YEAR ( 'Table'[Date] ) = YEAR ( TODAY () ) )
    )
VAR lastyear =
    CALCULATE (
        SUM ( 'Table'[value] ),
        SAMEPERIODLASTYEAR ( 'Table'[Date].[Date] )
    )
RETURN
     ( currentyear - lastyear ) / lastyear

matrix.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

You can try to create this measure to calculate the difference by samplepeoriod last year:

percent =
VAR currentyear =
    CALCULATE (
        SUM ( 'Table'[value] ),
        FILTER ( 'Table', YEAR ( 'Table'[Date] ) = YEAR ( TODAY () ) )
    )
VAR lastyear =
    CALCULATE (
        SUM ( 'Table'[value] ),
        SAMEPERIODLASTYEAR ( 'Table'[Date].[Date] )
    )
RETURN
     ( currentyear - lastyear ) / lastyear

matrix.png

Attached a sample file in the below, hopes to help you.

 

Best Regards,
Community Support Team _ Yingjie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@Anonymous , How week drill down created. You have created a week in the date table like

 

Week Start date = 'Date'[Date]+-1*WEEKDAY('Date'[Date],2)+1
Week End date = 'Date'[Date]+ 7-1*WEEKDAY('Date'[Date],2)
Week Number = WEEKNUM([Date],2)
Week = if('Date'[Week Number]<10,'Date'[Year]*10 & 'Date'[Week Number],'Date'[Year]&'Date'[Week Number])

 

and you are having measures like

sales = SUM(Sales[Sales Amount])

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

 

Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Power BI — Week on Week and WTD
https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-Last-Week/ba-p/1051123
https://www.youtube.com/watch?v=pnAesWxYgJ8

 

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.