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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! 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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.