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
Maheshguptaz
Helper III
Helper III

starting count (12 months ago)

Hi,

 

I'm trying to get the starting count from 12 months ago and it should be dynamic to perform R12 calculations. For example:

Ending count = Oct'21
Starting Count = Nov'20

 

I need help to get the starting count. Any suggestions?

Regards,
Mahesh

1 ACCEPTED SOLUTION

HI @Maheshguptaz 

 

Try this:

R12 Start number =
VAR _EndDate =
    MAX ( 'Calendar'[Date] )
VAR _StartDateS =
    DATE ( YEAR ( _EndDate ) - 1, MONTH ( _EndDate ) - 1, 1 )
VAR _StartDateF =
    ENDOFMONTH ( _StartDateS )
RETURN
    CALCULATE (
        COUNTA ( ExcelDB_Headcount[Employee ID] ),
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Date] >= _StartDateS
                && 'Calendar'[Date] <= _StartDateF
        )
    )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

View solution in original post

4 REPLIES 4
v-xiaotang
Community Support
Community Support

Hi @Maheshguptaz 

You can use Edate() or Eomonth(),

https://docs.microsoft.com/en-us/dax/edate-function-dax

https://docs.microsoft.com/en-us/dax/eomonth-function-dax

e.g.

Start Date = 
    VAR _date= MAX('DATE Table'[Date]) //in this example, max date in table is 2021/10/21
    var _start=EDATE(_date,-12)
RETURN _start

vxiaotang_1-1636608856751.png

Start Date = 
    VAR _date= MAX('DATE Table'[Date]) //in this example, max date in table is 2021/10/21
    var _start=EOMONTH(_date,-12)
RETURN _start


vxiaotang_2-1636608876293.png

 

 

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

Hi @Maheshguptaz 

 

You can use the PREVIOUSYEAR DAX function to find the solution.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

hi @VahidDM ,

I'm getting the total of last 12 months if I use the following DAX:

R12 Start number = CALCULATE(COUNTA(ExcelDB_Headcount[Employee ID]),PREVIOUSYEAR('Calendar'[Date]))
I'm trying to get only the count for a single month.


HI @Maheshguptaz 

 

Try this:

R12 Start number =
VAR _EndDate =
    MAX ( 'Calendar'[Date] )
VAR _StartDateS =
    DATE ( YEAR ( _EndDate ) - 1, MONTH ( _EndDate ) - 1, 1 )
VAR _StartDateF =
    ENDOFMONTH ( _StartDateS )
RETURN
    CALCULATE (
        COUNTA ( ExcelDB_Headcount[Employee ID] ),
        FILTER (
            ALL ( 'Calendar' ),
            'Calendar'[Date] >= _StartDateS
                && 'Calendar'[Date] <= _StartDateF
        )
    )

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.

Appreciate your Kudos!!

 

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.