Forum Discussion

qwertzuiop's avatar
qwertzuiop
Advocate III
4 years ago
Solved

date difference per value

Hello dear Power BI Community   Following problem: I would like to add in Power BI the 3th column given these informations: It should calculate the date difference per Product off the row above...
  • Jihwan_Kim's avatar
    4 years ago

    Hi,

    Please check the below picture and the attached pbix file.

    It is for creating a new column.

     

     

    Date Diff per Product CC =
    VAR _previousdate =
        MAXX (
            FILTER (
                Data,
                Data[Product] = EARLIER ( Data[Product] )
                    && Data[Date] < EARLIER ( Data[Date] )
            ),
            Data[Date]
        )
    RETURN
        IF ( _previousdate = BLANK (), 0, INT ( Data[Date] - _previousdate ) )