Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Create Card with Value by Date

hello, i have this powerbi dahsboard and all the details below:

 

 

 

 

I have 2 tables:

 

attendance table:

 

IdNameDateClock inClock OutAbsent
1Lebron6/1/202200:00:0000:00TRUE
1Lebron6/2/2022  07:0015:00Present
1Lebron6/3/2022  07:0015:00Present
1Lebron6/4/2022  07:0015:00Present
1Lebron7/3/2022  07:0015:00Present
1Lebron7/4/2022  07:0015:00Present
1Lebron7/5/2022  07:0015:00Present
1Lebron7/6/2022  07:0015:00Present
1Lebron8/1/2022  07:0015:00Present
1Lebron8/2/2022  07:0015:00Present
1Lebron8/3/2022  07:0015:00Present
1Lebron8/4/2022  07:0015:00Present
2Ari6/1/2022  07:0015:00Present
2Ari6/2/2022  07:0015:00Present
2Ari6/3/2022  07:0015:00Present
2Ari6/4/2022  07:0015:00Present
2Ari7/3/2022  07:0015:00Present
2Ari7/4/202200:00:0000:00TRUE
2Ari7/5/202200:00:0000:00TRUE
2Ari7/6/2022  07:0015:00Present
2Ari8/1/2022  07:0015:00Present
2Ari8/2/2022  07:0015:00Present
2Ari8/3/2022  07:0015:00Present
2Ari8/4/2022  07:0015:00Present

 

 

and employee table:

 

IdNameDatePayment per hourTotal days worked
1Lebron6/1/2022  13
1Lebron7/1/2022  1.254
1Lebron8/1/2022  1.754
2Ari6/1/202224
2Ari7/1/20222.52
2Ari8/1/20222.54

 

i want to find value of payment per hour each month. 

 

so if i put the month of august, when i press on ari, i get 2.5, while lebron 1.75

if i put month of june, if i press on ari, o get 2, while if i press lebron i get 1

 

SpartaBI amitchandak tamerj1 

  • Hi Anonymous 
    Actually the solution I provided in your previous post shall work fine with no issues. The reason is when the employee is absent then his time is already zero and no need to make any further filtering.

    https://www.dropbox.com/t/l7mnejNnTkgNaqr3

    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
                        && attendance[Absent] = "Present"
                ),
                VAR Clockin = attendance[Clock in]
                VAR Clockout = attendance[Clock Out]
                VAR NumberOfHours = DATEDIFF ( Clockin, Clockout, HOUR )
                RETURN
                    CurrentRate * NumberOfHours
            )
    )

1 Reply

  • tamerj1's avatar
    tamerj1
    Icon for Community Champion rankCommunity Champion

    Hi Anonymous 
    Actually the solution I provided in your previous post shall work fine with no issues. The reason is when the employee is absent then his time is already zero and no need to make any further filtering.

    https://www.dropbox.com/t/l7mnejNnTkgNaqr3

    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
                        && attendance[Absent] = "Present"
                ),
                VAR Clockin = attendance[Clock in]
                VAR Clockout = attendance[Clock Out]
                VAR NumberOfHours = DATEDIFF ( Clockin, Clockout, HOUR )
                RETURN
                    CurrentRate * NumberOfHours
            )
    )