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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

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
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 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.

Top Solution Authors
Top Kudoed Authors