Forum Discussion

JoonasOP's avatar
JoonasOP
New Member
4 years ago
Solved

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 numb...
  • Jihwan_Kim's avatar
    4 years ago

    Hi,

    Please check the below.

    It is for creating a new measure.

     

     

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