Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Change payment every month

hello i have 2 tables attendance: Id Name Date Clock in Clock Out 1 Lebron 06/01/22   07:00 15:00 1 Lebron 07/01/22   07:00 15:00 1 Lebron 08/01/22   07:00 15:00 2 A...
  • tamerj1's avatar
    4 years ago

    Hi Anonymous 
    Here is a sample file with the propsed solution https://www.dropbox.com/t/i3qSlzaPNNMgXE9D

    Monthly Salary Column = 
    VAR CurrentRate = employee[Payment per hour]
    VAR CurrentMonth = MONTH (  employee[Date] )
    VAR CurrentYear = YEAR ( employee[Date] )
    RETURN
        SUMX (
            FILTER ( 
                RELATEDTABLE ( attendance ), 
                MONTH ( attendance[Date] ) = CurrentMonth
                    && YEAR ( attendance[Date] ) = CurrentYear
            ),
            VAR Clockin = attendance[Clock in]
            VAR Clockout = attendance[Clock Out]
            VAR NumberOfHours = DATEDIFF ( Clockin, Clockout, HOUR )
            RETURN
                CurrentRate * NumberOfHours
        )
    Monthly Salary Measure = 
    SUMX (
        employee,
        VAR CurrentRate = employee[Payment per hour]
        VAR CurrentMonth = MONTH (  employee[Date] )
        VAR CurrentYear = YEAR ( employee[Date] )
        RETURN
            SUMX (
                FILTER ( 
                    RELATEDTABLE ( attendance ), 
                    MONTH ( attendance[Date] ) = CurrentMonth
                        && YEAR ( attendance[Date] ) = CurrentYear
                ),
                VAR Clockin = attendance[Clock in]
                VAR Clockout = attendance[Clock Out]
                VAR NumberOfHours = DATEDIFF ( Clockin, Clockout, HOUR )
                RETURN
                    CurrentRate * NumberOfHours
            )
    )