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
Deevo_
Resolver I
Resolver I

For each Staff, Count occurrences where 2 measure are TRUE for the same date

Hi All,

Thanks in advance. I apologise if I am asking or using the incorrect terms, I have tried my best to make it clear using sample data. I am unable to upload a PBIX file due to workplace permissions.

Context:

I have a group of 3 staff in 3 different Teams who record leave days OR submit timesheets OR do both for each workday. I need to count every occurrences when a staff records leave AND submits a timesheet for the same date.

What I am trying to achieve:

I have 3 staff members and for each staff member, I need a measure to count every occurence where 2 measures are TRUE.

  • Measures:
    • Leave Events= SUM([LeaveEventTotal])
    • Timesheet Hours submitted = SUM([Timesheet Hours])
  • I need to factor in the groupings by the Teams if possible, I may need to use conditional formatting at some point to colour the values only and not the Team Totals. (future task)

Datasets (Simplified sample data):

Date table:

DatekeyDate
2023060101/06/2023
2023060202/06/2023
2023060303/06/2023

Staff Details Table:

Logon IDStaff NameTeamID
AA001Alex Apple1
BB002Bob Banana2
CC003Charlie Cucumber3

Team Names Table:

TeamIDTeam Name
1Alpha
2Bravo
3Charlie

Leave Table:

DateKeyLeave DateLogon IDStaff NameLeaveEventTotal
2023060202/06/2023BB002Bob Banana1
2023060303/06/2023CC003Charlie Cucumber1

Timesheets Table:

DateKeyTimesheet DateLogon IDStaff NameTimesheet Hours
2023060101/06/2023AA001Alex Apple5
2023060202/06/2023BB002Bob Banana10
2023060303/06/2023CC003Charlie Cucumber(blank)

 

Report Display Output:

Date 01/06/202301/06/202302/06/202302/06/202303/06/202303/06/2023

Team Name

Staff NameTotal Leave EventsTimesheet Hours submitted Total Leave EventsTimesheet Hours submitted Total Leave EventsTimesheet Hours submitted
Alpha       
 Alex Apple(blank)5(blank)(blank)(blank)(blank)
Bravo       
 Bob Banana(blank)(blank)110(blank)(blank)
Charlie       
 Charlie Cucumber(blank)(blank)(blank)(blank)1(blank)

 

Expected Result:

  • Over the 3 days period, I expect a resulting count = 1.
    • In my Report display output table, Team Bravo has staff Name "Bob Banana" who has a Leave event and Timesheet hours recorded on the same date (02/06/2023). The other 2 staff Names do not meet the criteria and should not be included in the total count.

Many thanks!

5 REPLIES 5
tamerj1
Super User
Super User

Hi @Deevo_ 
Please try

Count =
SUMX (
    CROSSJOIN ( VALUES ( 'Team Names'[Team Name] ), VALUES ( 'Date'[Date] ) ),
    INT ( [Leave Events] + [Timesheet Hours submitted] <> BLANK () )
)

Hi Tamerj1, I appreciate your time. This almost works, it seems to be counting the occurrences and then multiplying the count by 3 times. Not sure why?

Can you please explain the Cross Join and the values inside? I believe i need to add more values inside the CROSS Join for it to count correctly. I tried adding "VALUES ('Staff Details'[Staff Name])" to the cross join and it seems to count correctly.

Your advice would be great.

Hi @Deevo_ 
Yea you are right. Please refer to attached sample file with the proposed solution. I have added a calculated table that should clarify how CROSSJOIN works.

1.png

Count = 
SUMX (
    CROSSJOIN ( VALUES ( 'Staff Details'[Staff Name] ), VALUES ( 'Date'[Date] ) ),
    INT ( [Leave Events] <> BLANK ( ) && [Timesheet Hours submitted] <> BLANK () )
)

 

Hi Tamerj1, Thank you for providing a refined solution, this is working perfectly.

  1. However, i cant see the calculated table inside the PBIX file?
  2. Do I have to enable some options to see this? I am using PowerBI desktop Version: 2.112.1421.0 64-bit (January 2023).

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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.