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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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])

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
Greg_Deckler
Community Champion
Community Champion

@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!:
DAX For Humans

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
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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