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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.