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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
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.

Top Solution Authors