Forum Discussion

JARONN's avatar
JARONN
Frequent Visitor
6 years ago
Solved

Problem with hour calculation

Person id        Index 1       Code        Work Order     Index 2            date/time        in/out calculation 1                     50               in                                     102    ...
  • v-juanli-msft's avatar
    6 years ago

    Hi JARONN 

    If i understand you correctly, 

    first add a index column in Edit queries,

    then create calculated columns in Data model view,

    out =
    CALCULATE (
        LASTNONBLANK ( Sheet1[Code], 0 ),
        FILTER (
            ALLEXCEPT ( Sheet1, Sheet1[person id ] ),
            Sheet1[Index 1]
                = EARLIER ( Sheet1[Index 1] ) + 1
                && Sheet1[Index] > EARLIER ( Sheet1[Index] )
        )
    )
    
    condition = IF([out]="out","in",IF([out]="<>out","out"))
    
    in/out cal =
    CALCULATE (
        LASTNONBLANK ( Sheet1[condition], 0 ),
        FILTER (
            ALLEXCEPT ( Sheet1, Sheet1[person id ] ),
            Sheet1[Index] <= EARLIER ( Sheet1[Index] )
        )
    )
    
    

    Best Regards
    Maggie
    Community Support Team _ Maggie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.