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
jlaroo33
Frequent Visitor

COUNTROWS based off of most recent file date not wokring

Hello! I am working on an employee headcount report, where my data builds each day with a new report run date. I am trying to capture the number of active Males and the number of active Females as of today. The measure I'm using to count the active employees is:

 

Active Employees NEW =
CALCULATE(
COUNTROWS('HeadCount_Term_Report NEW'),
LASTDATE('HeadCount_Term_Report NEW'[Report Run Date]))
 
The issue I'm having is that 2 employees had previously had the Gender "Not Specified" when they were first hired and the gender has since been updated, but those two records are still being counted in my totals on the visual. 
 
I hope this makes sense! Thank you in advance!
 
Jodi
1 ACCEPTED SOLUTION
jlaroo33
Frequent Visitor

@tamerj1 , actually disregard that! I missed entering the actual employee IDs into "emp 1" and "emp 2". 


Thank you so much!

 

View solution in original post

3 REPLIES 3
jlaroo33
Frequent Visitor

@tamerj1 , actually disregard that! I missed entering the actual employee IDs into "emp 1" and "emp 2". 


Thank you so much!

 

tamerj1
Super User
Super User

Hi @jlaroo33 

If these are the only 2 employees tha had the Gender "Not Specified" and there are no other record that has the Gender "Not Specified" then you may try

Active Employees NEW =
CALCULATE (
    COUNTROWS ( 'HeadCount_Term_Report NEW' ),
    LASTDATE ( 'HeadCount_Term_Report NEW'[Report Run Date] ),
    'HeadCount_Term_Report NEW'[Gender] <> "Not Specified"
)

In case you have records that have the gender "Not Specified" other than these 2 employees and you want them to be included with the count then you may try

Active Employees NEW =
VAR ExcludedRecords =
    CALCULATETABLE (
        'HeadCount_Term_Report NEW',
        'HeadCount_Term_Report NEW'[empID] IN { "emp1", "emp2" },
        'HeadCount_Term_Report NEW'[Gender] = "Not Specified"
    )
VAR LastDateTable =
    CALCULATETABLE (
        'HeadCount_Term_Report NEW',
        LASTDATE ( 'HeadCount_Term_Report NEW'[Report Run Date] )
    )
RETURN
    COUNTROWS ( EXCEPT ( LastDateTable, ExcludedRecords ) )

Hi @tamerj1 ,

 

Thank you for looking into my issue. Unfortunately, the second formula that you provided (which is what I want, to include other "Not Specified" employees) did not see to work. Those two records are still being counted. 

 

Thank you, Jodi

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.