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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

aggregate count over month

Dear Team,

I have a table with students id and date attended.I have a requirement for line chart to show count of students.The x axis will be months and y axis represent the count.I need to show 2 charts. In the first graph I must plot count of students attended in one month which I was able to show.In the second graph, requirement is to count number of students attended by 3 months i.e on jan we must show sum of counts of students attened in nov,dec and jan,for feb-dec,jan,feb etc…Is this possible to show?Pls advice as required.Thank you for your time.

 

Regards

Rishi

1 ACCEPTED SOLUTION
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Could you try the formula below to see if it works in your scenario? Smiley Happy

Measure =
VAR __LAST_DATE =
    ENDOFMONTH ( 'DimDate'[Date].[Date] )
VAR __DATE_PERIOD =
    DATESBETWEEN (
        'DimDate'[Date].[Date],
        STARTOFMONTH ( DATEADD ( __LAST_DATE, -3, MONTH ) ),
        ENDOFMONTH ( __LAST_DATE )
    )
RETURN
    CALCULATE ( COUNTROWS ( 'Table1' ), __DATE_PERIOD )

Note:

1. "DimDate" table is an individual Calendar table, if you don't one yet, you can use CALENDARAUTO to create it and then create a relationship between your fact table(with students id and date attended) and this DimDate table.

DimDate = CALENDARAUTO()

2. Replace "Table1" with your real fact table name.

 

Regards

View solution in original post

2 REPLIES 2
v-ljerr-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous,

 

Could you try the formula below to see if it works in your scenario? Smiley Happy

Measure =
VAR __LAST_DATE =
    ENDOFMONTH ( 'DimDate'[Date].[Date] )
VAR __DATE_PERIOD =
    DATESBETWEEN (
        'DimDate'[Date].[Date],
        STARTOFMONTH ( DATEADD ( __LAST_DATE, -3, MONTH ) ),
        ENDOFMONTH ( __LAST_DATE )
    )
RETURN
    CALCULATE ( COUNTROWS ( 'Table1' ), __DATE_PERIOD )

Note:

1. "DimDate" table is an individual Calendar table, if you don't one yet, you can use CALENDARAUTO to create it and then create a relationship between your fact table(with students id and date attended) and this DimDate table.

DimDate = CALENDARAUTO()

2. Replace "Table1" with your real fact table name.

 

Regards

Anonymous
Not applicable

@v-ljerr-msftThanks for the solution.It worked!!!

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.