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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
rishabjain237
Helper I
Helper I

average count of 3 months for every month in matrix.

Hi guys,
I need to caclulate the average count of 3 months for every month in a matrix.

rishabjain237_0-1695189404761.png

For example : For August month The numbers which should be displayed is the average of June+july+august. and for july it should be July+june+may and so on. Please provide a measure for this. 
The columns Iam using :
'Master append'[Groups] - in Rows
'Master append'[Month] - in Columns
'Measures Table'[TotalLeadsForSales] - in values. where,

TotalLeadsForSales = CALCULATE(COUNT('Master append'[Lead_Type]),'Master append'[lang]="English",'Master append'[Lead_Type]="Business")
Lead_type was used because its a column with no null values.


Thanks and Regards.
Rishab Jain.

1 ACCEPTED SOLUTION

Hello sir @parry2k , Thanks for the reply.
I have tried the given code but problem still remains.

rishabjain237_0-1695900793679.png
The average is only displayed in totals column. I want to display the average of 3 month(includes present month) for every month. For example the august column should have the average of jun july aug and the july should have avg of july june and may.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@rishabjain237 I think you need this:

 

Test 3 =
VAR numofmonths = 3
VAR LastSelectedDate = MAX('Master append'[Date])
VAR Period =
    DATESINPERIOD('Master append'[Date],LastSelectedDate,-numofmonths,MONTH)
VAR Result =
    CALCULATE(
            AVERAGEX(
                VALUES('Master append'[Month]),
                [TotalLeadsForSales]
            ),
            Period
     )
Return
Result


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Hello sir @parry2k , Thanks for the reply.
I have tried the given code but problem still remains.

rishabjain237_0-1695900793679.png
The average is only displayed in totals column. I want to display the average of 3 month(includes present month) for every month. For example the august column should have the average of jun july aug and the july should have avg of july june and may.

rishabjain237
Helper I
Helper I

I have tried to this formula :

Test 3 =
VAR numofmonths = 3
VAR LastSelectedDate = MAX('Master append'[Date])
VAR Period =
    DATESINPERIOD('Master append'[Date],LastSelectedDate,-numofmonths,MONTH)
VAR Result =
    CALCULATE(
            AVERAGEX(
                VALUES('Master append'[Month]),
                MeasuresTable[TotalLeadsForSales]),Period)
Return
Result
But the average is being displayed in totals column :
rishabjain237_0-1695226240063.png

@parry2k @amitchandak Please need your advice in this. amit sir I have seen your weekly comparison videos. it was very help full. Thanks!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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