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! Request now

Reply
sarvesh23p
New Member

Compare current record with previous record within same column on the basis date-time column

Hi All,

 

I have a table which have Date tiem columns and a data columns. Consider column name  'high'

I want to compare recirds with the previous value on same column on the basis on datetime column.

sarvesh23p_0-1663062905776.png

The above is the sample ss of the data. How can i achive this?

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @sarvesh23p ,

 

Please try this code to create a measure.

Open Diff =
VAR _Previous_Datetime =
    CALCULATE (
        MAX ( 'Table'[Datetime] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Datetime] < MAX ( 'Table'[Datetime] ) )
    )
VAR _Previous_value =
    CALCULATE (
        SUM ( 'Table'[Open] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Datetime] = _Previous_Datetime )
    )
VAR _Current_value =
    CALCULATE ( SUM ( 'Table'[Open] ) )
RETURN
    _Current_value - _Previous_value

My Sample:

RicoZhou_0-1663145832367.png

Result is as below.

RicoZhou_1-1663145855209.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @sarvesh23p ,

 

Please try this code to create a measure.

Open Diff =
VAR _Previous_Datetime =
    CALCULATE (
        MAX ( 'Table'[Datetime] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Datetime] < MAX ( 'Table'[Datetime] ) )
    )
VAR _Previous_value =
    CALCULATE (
        SUM ( 'Table'[Open] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Datetime] = _Previous_Datetime )
    )
VAR _Current_value =
    CALCULATE ( SUM ( 'Table'[Open] ) )
RETURN
    _Current_value - _Previous_value

My Sample:

RicoZhou_0-1663145832367.png

Result is as below.

RicoZhou_1-1663145855209.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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