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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

count rows containing blank and date values for a given month

Hi there,

I am trying to build an HR report showing employee counts per month that I can compare  to a forecast.

I have a (calculated) column containing end of contract dates and blanks. One row represents a unique employee. It seems logical to me that I should do something like this:

Total rows – (rows containing date < Month) = employees at a given Month.

I’m quite new to PowerBi and my Dax knowledge is limited. So far I’ve been able to get a table showing the count of employees with an end of contract date per given month using this measure:

measure=
if(not(isblank(max(Datetable[Datum]))),

CALCULATE(distinctcount(Table1[rows.employee]),

USERELATIONSHIP(Table1[enddate_calculated],

Datetable[Datum])),

blank())

However, I can’t find a way to use this to subtract it from the total row count in a way that I can visualize it per month.

Any suggestions on how to get the desired result?

Thanks in advance!

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below to get the count of employees:

Employee Count =
VAR __DATE =
    MAX ( 'datetable'[Date] )
RETURN
    SUMX (
        Table1,
        IF (
            Table1[DateStarted] <= __DATE
                && OR (
                    Table1[enddate_calculated] >= __DATE,
                    ISBLANK ( Table1[enddate_calculated] )
                ),
            1,
            BLANK ()
        )
    )

And you can refer the following links to get it:

How Many Staff Do We Currently Have – Multiple Dates Logic In Power BI Using DAX


Create inactive relationshipsCreate inactive relationships
Create measureCreate measureCreate visualsCreate visuals

Count Amount of Active Employees by period

Counting “Active” Rows in a Time Period: Guest Post from Chris Campbell

Best Regards

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

You can create a measure as below to get the count of employees:

Employee Count =
VAR __DATE =
    MAX ( 'datetable'[Date] )
RETURN
    SUMX (
        Table1,
        IF (
            Table1[DateStarted] <= __DATE
                && OR (
                    Table1[enddate_calculated] >= __DATE,
                    ISBLANK ( Table1[enddate_calculated] )
                ),
            1,
            BLANK ()
        )
    )

And you can refer the following links to get it:

How Many Staff Do We Currently Have – Multiple Dates Logic In Power BI Using DAX


Create inactive relationshipsCreate inactive relationships
Create measureCreate measureCreate visualsCreate visuals

Count Amount of Active Employees by period

Counting “Active” Rows in a Time Period: Guest Post from Chris Campbell

Best Regards

Anonymous
Not applicable

Hi @amitchandak,
That looks great! I will try it out, as it exeeds my original requirements.

Meanwhile another working solution was offerd to me (by a colleague) in the form of this formula:

measure =
VAR selectedDate= MAX(datetable[Date])
RETURN
SUMX(Table1,
VAR INDIENSTDATUM = Table1[rows.Start_contract]
VAR UITDIENSTDATUM =Gegevens_Externe_Medewerkers[rows.End_contract_set]
RETURN IF(INDIENSTDATUM<= selectedDate && OR(UITDIENSTDATUM>=selectedDate, UITDIENSTDATUM=blank()
),1,0)
)
amitchandak
Super User
Super User

@Anonymous , refer if this can help

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

 

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors