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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Day over Day Dax question

I have a data set that has a list of 5 different products and daily prices for each, for example

Date    Product    Price

09/09     A            $1.00

09/09     B             $1.50

09/09     C             $0.50

09/08     A             $0.75

09/08     B             $1.25

09/08     C             $1.30

 

I also have a date table set up for this BI report. I need to calculate day over day change and need some help figuring out the DAX. Prices are only published Mon-Friday, so I need the DAX to recognize not to calculate if there isn't a price for the previous date (Ex, weekends and holidays). Maybe the Dax can just take most recent price and the last price and get the difference?

 

Thank you for your help. 

4 REPLIES 4
amitchandak
Super User
Super User

@Anonymous , Try a new column like

new column =
var _max = MAXX(FILTER(Table,[Date] < EARLIER([Date]) && [Product] = EARLIER([Product])),[Date])
return
[Price]- MAXX(FILTER(Table,[Date] =_date && [Product] = EARLIER([Product])),[Price])

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Greg_Deckler
Super User
Super User

@Anonymous You need to EARLIER. See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/339586.
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

This got me close but not exact. Below is a list of the numbers I need vs what the DAX formau you provided is giving me. I think I need to add a filter for product somewhere, but I just can't get it right. I checked on excel using basic formaul of (current-previous)/previous). On my report, I will end up showing these numbers as %Change Day over Day

 

Date          Product      Price        Day over Day change      # retruned from DAX formual

09/01            A             1.4650

09/02            A             1.5100             0.0307                           -0.49670

09/03            A             1.5000             -0.0066                         -0.50000

09/04           A              1.4925            -0.0050                           -0.50250

09/01           B              1.8025

09/02           B              1.9100               0.0596                          -0.36330

09/03           B              2.0525               0.0746                         -0.31580

09/04           B              2.1250               0.0353                           -0.29170

Anonymous
Not applicable

This got me close but not exact. Below is a list of the numbers I need vs what the DAX formau you provided is giving me. I think I need to add a filter for product somewhere, but I just can't get it right. I checked on excel using basic formaul of (current-previous)/previous). On my report, I will end up showing these numbers as %Change Day over Day

 

Date          Product      Price        Day over Day change      # retruned from DAX formual

09/01            A             1.4650

09/02            A             1.5100             0.0307                           -0.49670

09/03            A             1.5000             -0.0066                         -0.50000

09/04           A              1.4925            -0.0050                           -0.50250

09/01           B              1.8025

09/02           B              1.9100               0.0596                          -0.36330

09/03           B              2.0525               0.0746                         -0.31580

09/04           B              2.1250               0.0353                           -0.29170

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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