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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
JoonasOP
New Member

Days between duplicates

Hi all!

 

I have list of repair orders with each having unique repair order number and serial number associated to product.

I want to count days between each duplicate record when same serial number has been associated with other repair order previously. Hopefully I was able to explain my problem clearly. 😁

 

Example:

 

Order num.                Serial                Repair completed               Days from previous order

0001                          12345                10/10/2021                        N/A

0002                          54321                12/10/2021                        N/A

0003                          13523                15/10/2021                        N/A

0004                          12345                16/10/2021                        6

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

Please check the below.

It is for creating a new measure.

 

Picture1.png

 

Days from previous order: =
VAR currentserial =
MAX ( Data[Serial] )
VAR currentordernumber =
MAX ( Data[Order num] )
VAR currentdate =
MAX ( Data[Repair completed] )
VAR previousdate_sameserial =
MAXX (
FILTER (
ALL ( Data ),
Data[Serial] = currentserial
&& Data[Order num] < currentordernumber
),
Data[Repair completed]
)
RETURN
IF (
HASONEVALUE ( Data[Order num] ),
IF (
ISBLANK ( previousdate_sameserial ),
"N/A",
INT ( currentdate - previousdate_sameserial )
)
)


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

Please check the below.

It is for creating a new measure.

 

Picture1.png

 

Days from previous order: =
VAR currentserial =
MAX ( Data[Serial] )
VAR currentordernumber =
MAX ( Data[Order num] )
VAR currentdate =
MAX ( Data[Repair completed] )
VAR previousdate_sameserial =
MAXX (
FILTER (
ALL ( Data ),
Data[Serial] = currentserial
&& Data[Order num] < currentordernumber
),
Data[Repair completed]
)
RETURN
IF (
HASONEVALUE ( Data[Order num] ),
IF (
ISBLANK ( previousdate_sameserial ),
"N/A",
INT ( currentdate - previousdate_sameserial )
)
)


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Woah! Thanks! This one did it! 🙂

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.