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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
NewbieJono
Post Partisan
Post Partisan

Difference in previous week

i have a table with a total snapshot on friday e.g 100. what dax would i need to show the increase or decrease from previous friday.

 

 

1 ACCEPTED SOLUTION
goncalogeraldes
Super User
Super User

Hello there @NewbieJono ! Imagining you are adding up the values for a column the Dax would be as follows:

 

Total_value =
CALCULATE(
SUM(Table[Column]),
DATEADD(Date_Table[Date_Column], -7, DAY)
)

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

View solution in original post

5 REPLIES 5
speedramps
Super User
Super User

Try this ...

Variance % =

VAR salesthisweek =
SUM(Query[Sale])

VAR salespreviousweek =
CALCULATE(SUM(Query[Sale]),
DATEADD(Query[Date],-7,DAY)
)

RETURN
DIVIDE(salespreviousweek , salesthisweek)
 
sm_talha
Resolver II
Resolver II

You can add Relative Week column into your date table and calculate total snapshot for last week and current week then the difference between both weeks. 

 

For Relative Week add following columns to date table:  

StartOfWeek = DimDate[Date] - WEEKDAY(DimDate[Date],2) + 1

StartOfCurrentWeek = TODAY() - WEEKDAY(TODAY(),2) + 1

RelativeWeek = (DimDate[StartOfWeek] - DimDate[StartOfCurrentWeek])/7

 

Now can create a measure to calculate weekly difference: 

 

WoW DIff = 

WoW diff =
VAR past_week =
    CALCULATE( [Total Cost], 'Date'[Relative Week] = -1 )
VAR cur_week =
    CALCULATE( [Total Cost], 'Date'[Relative Week] = 0 )
RETURN
    cur_week - past_week

 

goncalogeraldes
Super User
Super User

Hello there @NewbieJono ! Imagining you are adding up the values for a column the Dax would be as follows:

 

Total_value =
CALCULATE(
SUM(Table[Column]),
DATEADD(Date_Table[Date_Column], -7, DAY)
)

 

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

this is working thank you, how could i expand this to show % change ?

Hello there @NewbieJono ! You can do it like so:

 % Change =

var _current = SUM(Table[Column])

var _previous =
CALCULATE( SUM( Table[Column] ),
DATEADD( Date_Table[Date_column], -7, DAY)
)

var _diff = _current - _previous

RETURN
DIVIDE(_diff, _previous) 

And then format the value as a "%" in the "Format" ribbon!

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.