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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Measure to calculate count for same month previous year

I have the below fields in my table.

 

Employee ID, Start Date, End Date

 

I need to find the active employess present for previous year same month. (current month is Apr 2021, so the formula shoud take today as current date and give the filter for Apr 2020)

 

Start date <= Apr 30th 2020 AND (End date >= Apr 1st 2020 OR End date is Blank)

 

Please help

 

 

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @Anonymous  ,


You could create a measure by the following formula:

count =
COUNTROWS (
    SUMMARIZE (
        FILTER (
            'Table',
            EOMONTH ( [Start date], 0 ) <= EOMONTH ( TODAY (), -12 )
                && (
                    EOMONTH ( [End date], 0 ) >= EOMONTH ( TODAY (), -12 )
                        || [End date] = BLANK ()
                )
        ),
        'Table'[Name]
    )
)

The final output is shown below:

v-yalanwu-msft_0-1619513053686.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-yalanwu-msft
Community Support
Community Support

Hi @Anonymous  ,


You could create a measure by the following formula:

count =
COUNTROWS (
    SUMMARIZE (
        FILTER (
            'Table',
            EOMONTH ( [Start date], 0 ) <= EOMONTH ( TODAY (), -12 )
                && (
                    EOMONTH ( [End date], 0 ) >= EOMONTH ( TODAY (), -12 )
                        || [End date] = BLANK ()
                )
        ),
        'Table'[Name]
    )
)

The final output is shown below:

v-yalanwu-msft_0-1619513053686.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Fowmy
Super User
Super User

@Anonymous 

You can try the following measure to get the count:

Emp Count = 
VAR MinDate =
    EOMONTH(TODAY(),-13) + 1
VAR MaxDate =
    EOMONTH(TODAY(),-12)
RETURN
COUNTROWS(    
    FILTER(
        Table,
        EndDate=BLANK() OR 
        (
            EndDate >= MinDate &&
            StartDate <= MaxDate
        )
    )
)

 

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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