Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Create Card with Value by Date

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

 

 

Dashboard.pngatt table.pngem table.pngrlationship.png

 

 

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 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

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

1.png

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
        )
)

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

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

1.png

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
        )
)

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.