Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Return Earlier or previous Date row data based two conditions - sequence and Tool number

I have a Dataset for an Item-"Tool" which is used more than one time , Everytime it is  used there is an increamental "Sequence" recorded and the end "Date Out" with reason . It returns to Base for S...
  • Jihwan_Kim's avatar
    4 years ago

    Hi,

    Please check the below DAX formula and the attached pbix file.

    It is for creating a new column.

     

    Previous reason CC =
    VAR currenttool = Data[Tool]
    VAR currentdate = Data[Date Out]
    VAR previousdate =
        MAXX (
            FILTER ( Data, Data[Tool] = currenttool && Data[Date Out] < currentdate ),
            Data[Date Out]
        )
    VAR currentsequence = Data[Sequence]
    VAR previoussequence =
        MAXX (
            FILTER ( Data, Data[Tool] = currenttool && Data[Sequence] < currentsequence ),
            Data[Sequence]
        )
    RETURN
        MAXX (
            FILTER (
                Data,
                Data[Tool] = currenttool
                    && Data[Date Out] = previousdate
                    && Data[Sequence] = previoussequence
            ),
            Data[Reason]
        )