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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
HILGARTH
Frequent Visitor

Counting days between different changes made to a record

To a table a copy of the initial record is added when there was a change.

I would like to calculate the days between these changes so that I know how many days passed between the different kinds of status.

 

Record ID

Product

Status

Record created

Date of last change

 

1

Trouser

Ordered

2023-10-11

2023-10-11

 

1

Trouser

Shipped

2023-10-11

2023-10-12

 

1

Trouser

Delivered

2023-10-11

2023-10-23

 

 

This means I should be able to display results like:

Days between Status “Ordered” and “Shipped” = 1 day

Days between Status “Shipped” and “Delivered” = 12 days

Days between Status "Shipped” and “Delivered" = 11 days

How to do this in Power BI?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi HILGARTH,

May I ask if this is the expected output you are looking for? Based on your description, I calculated days between Status Ordered and Shipped and Shipped and Delivered, The following table shows the effect of the display.

 

vyaningymsft_0-1700468782424.png

 

 

Step: Create a new Calculated column, and drag the new Calculated column to the table visual.

Column =

DATEDIFF (

    CALCULATE (

        MAX ( 'Table'[Date of last change] ),

        FILTER (

            ALL ( 'Table' ),

            EARLIER ( 'Table'[Date of last change] ) > 'Table'[Date of last change]

                && 'Table'[Record ID] = EARLIER ( 'Table'[Record ID] )

        )

    ),

    'Table'[Date of last change],

    DAY

)

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi HILGARTH,

May I ask if this is the expected output you are looking for? Based on your description, I calculated days between Status Ordered and Shipped and Shipped and Delivered, The following table shows the effect of the display.

 

vyaningymsft_0-1700468782424.png

 

 

Step: Create a new Calculated column, and drag the new Calculated column to the table visual.

Column =

DATEDIFF (

    CALCULATE (

        MAX ( 'Table'[Date of last change] ),

        FILTER (

            ALL ( 'Table' ),

            EARLIER ( 'Table'[Date of last change] ) > 'Table'[Date of last change]

                && 'Table'[Record ID] = EARLIER ( 'Table'[Record ID] )

        )

    ),

    'Table'[Date of last change],

    DAY

)

 

If this does not work, could you please share some sample data without sensitive information and expected output.
How to provide sample data in the Power BI Forum - Microsoft Fabric Community

Best Regards,
Yang
Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Dear Yang

Great - that works!

thx & best regards

wdx223_Daniel
Super User
Super User

=VAR _d=MAX(Table[Date of last change]) RETURN _d+1-COALESCE(CACULATE(MAX(Table[Date of last change]),Table[Date of last change]<_d,ALLEXCEPT(Table,Table[Record ID]),MAX(Table[Record Created]))

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.