Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Miguelcrz
Helper I
Helper I

WEEK VARIATION

Hello,

 

I need to have the variation % of my sales comparing it vs the last week like this:

 

Miguelcrz_0-1597354193061.png

 

 

My power BI currently looks like this:

 

Miguelcrz_1-1597354216692.png

And my table of time looks like this (Semanacal = Number of the week):

 

Miguelcrz_3-1597354255772.png

 

I've also looked at the forum the questions of people that had the same issue but isn't working for me.

 

Thanks!

 

 

10 REPLIES 10
amitchandak
Super User
Super User

@Miguelcrz , first of all have a separate week table. Should include the year in that.  The best way is to use week year rank , Please follow my blog for that.

With week no. The date can Week -year/week table

This Week = CALCULATE(sum('order'[sales]), FILTER(ALL('Date'),'Date'[Week]=max('Date'[Week])))
Last Week = CALCULATE(sum('order'[sales]), FILTER(ALL('Date'),'Date'[Week]=max('Date'[Week])-1))

 

With Rank

This Week = CALCULATE(sum('order'[sales]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[sales]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))

 

refer these to see how rank works

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-La...

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @Miguelcrz,

You can try to use the following measure formula if it meets your requirement.

Measure =
VAR currWeek =
    MAX ( table[Week] )
VAR prevSales =
    CALCULATE (
        SUM ( table[Sales] ),
        FILTER ( ALLSELECTED ( table ), [Week] = currWeek - 1 )
    )
RETURN
    DIVIDE ( SUM ( table[Sales] ) - prevSales, prevSales, -1 )

If above not help, please provide some dummy data to help us clarify your scenario and do test coding formula on it.
Regards,

Xiaoxin Sheng

FrankAT
Community Champion
Community Champion

Hi @Miguelcrz 

is that what you are looking for?

 

14-08-_2020_00-13-05.png

 

Regards FrankAT

Anand24
Super User
Super User

Hi @Miguelcrz ,

 

Can you create a new column with below DAX:

Last Calendar Week Sales = CALCULATE( [Total Sales], 'Calendar'[Week Number] = WEEKNUM(TODAY(),1) -1 )

 

Use this to create another calculated column for % variation with below DAX:

Percent_Variation = (([Total Sales]-[Last Calendar Week Sales])/[Last Calendar Week Sales])*100

 

Give a thumbs up if this post helped you in any way and mark this post as solution if it solved your query !!!

Hi @Anand24 @amitchandak @v-shex-msft @FrankAT ! is not working. I only have the column week and the column sales. I have to calculate or do a new column to calculate the sales from last week but i dont know how. Then i need to calculate the variation between the sales of this week vs last week.

Thanks!

Hi @Miguelcrz 

here is another solution to your question. Use the three measures below.

 

15-08-_2020_01-53-27.png

 

Regards FrankAT

HI @FrankAT , it doesnt work :(.

Anonymous
Not applicable

Hi @Miguelcrz,

You told us these codes not works without any detailed information, they not help to resolve your scenario and hard to clarify/troubleshoot the issues.
Can you please provide a pbix file with dummy data and formulas to test? I think it should help for testing the coding formula on your sample data. (remove sensitive data before share)

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Hi! is not working. I only have the column week and the column sales. I have to calculate or do a new column to calculate the sales from last week but i dont know how. Then i need to calculate the variation between the sales of this week vs last week.

Thanks!

Hi @Miguelcrz

here another solution to your question. Use the three measures below.

15-08-_2020_01-53-27.png

Regards FrankAT

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.