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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Tracking price movement against previous price (without time series) using DAX

Hi there,  I am looking for DAX solution to derive the previous price based on price revision sequence.  Unfortunately, I cannot use date functions as the underlying data does not hold time dimensions.  I have attached below the sample table details, the last column requires DAX formula to derive the unique price based on combination of  Product, Location and previous seq no.  Many thanks. 

 

ProductLocationPrice Revision SeqCurrent PricePrevious Price (DAX)
CokeNewYork1 $1.00 N/A
CokeNewYork2 $1.10 $1.00
CokeNewYork3 $1.25 $1.10
CokeLA1 $1.10 N/A
CokeLA2 $1.25 $1.10
CokeLA3 $1.30 $1.25
PepsiNewYork1 $0.80 N/A
PepsiNewYork2 $1.00  $0.80 
PepsiNewYork3 $1.15  $1.00 
PepsiLA1 $0.85 N/A
PepsiLA2 $1.15  $0.85 
PepsiLA3 $1.20  $1.15 
2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Anonymous 

Try like

Previous Price (DAX) = maxx(filter(table, table[Product] =earlier(table[Product] ) && table[Location] =earlier(table[Location] )
								&& table[	Price Revision Seq] =earlier(table[	Price Revision Seq] ) -1),Table[Current 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

View solution in original post

v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please create a calculated column as below.

Previous Price = 
VAR ind = 'Table'[Price Revision Seq] - 1
VAR pre =
    CALCULATE (
        MAX ( 'Table'[Current Price] ),
        FILTER (
            'Table',
            'Table'[Product] = EARLIER ( 'Table'[Product] )
                && 'Table'[Location] = EARLIER ( 'Table'[Location] )
                && 'Table'[Price Revision Seq] = ind
        )
    )
RETURN
    pre

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

Write this calculated column formula

Column = LOOKUPVALUE(Data[Current Price],Data[Product],Data[Product],Data[Location],Data[Location],Data[Price Revision Seq],CALCULATE(MAX(Data[Price Revision Seq]),FILTER(Data,Data[Product]=EARLIER(Data[Product])&&Data[Location]=EARLIER(Data[Location])&&Data[Price Revision Seq]<EARLIER(Data[Price Revision Seq]))))

Hope this helps.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

Please create a calculated column as below.

Previous Price = 
VAR ind = 'Table'[Price Revision Seq] - 1
VAR pre =
    CALCULATE (
        MAX ( 'Table'[Current Price] ),
        FILTER (
            'Table',
            'Table'[Product] = EARLIER ( 'Table'[Product] )
                && 'Table'[Location] = EARLIER ( 'Table'[Location] )
                && 'Table'[Price Revision Seq] = ind
        )
    )
RETURN
    pre

Capture.PNG

 

Pbix as attached.

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
amitchandak
Super User
Super User

@Anonymous 

Try like

Previous Price (DAX) = maxx(filter(table, table[Product] =earlier(table[Product] ) && table[Location] =earlier(table[Location] )
								&& table[	Price Revision Seq] =earlier(table[	Price Revision Seq] ) -1),Table[Current 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
Anonymous
Not applicable

Thanks for prompt response and solution.  The logic works for most of the cases assuming it has like for like data values.  It does not work if any of the product is added which was not available previously.  See the example below.  Is there a way to show -482.914 for the missing product so that there is no overall price change. Many thanks in advance.

 

ProductRev 1Rev 2DAX(Variance)Comment
Direct - 100   482,914            482,914 
None - 000  482,914 -           482,914Not Shown
Grand Total  482,914  482,914                       -   

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors