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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
jcastr02
Post Prodigy
Post Prodigy

Avg number of items per month (only last completed month)

I am trying to do an avg number of records per month but I only want it to count through the last complete month.  In other words, if today is 11/8/2024, I want it to only    count records through 10/31/2024.  

My table has below two columns

RecordID           Created           

1 ACCEPTED SOLUTION
saud968
Solution Sage
Solution Sage

To calculate the average number of records per month up to the last completed month in Power BI, you can follow these steps:

Create a new column to extract the month and year from the Created column:
MonthYear = FORMAT('YourTable'[Created], "YYYY-MM")

Create a measure to count the records up to the last completed month:
TotalRecords =
CALCULATE(
COUNT('YourTable'[RecordID]),
'YourTable'[Created] < EOMONTH(TODAY(), -1) + 1
)

Create a measure to count the distinct months up to the last completed month:
DistinctMonths =
CALCULATE(
DISTINCTCOUNT('YourTable'[MonthYear]),
'YourTable'[Created] < EOMONTH(TODAY(), -1) + 1
)

Create a measure to calculate the average number of records per month:
AvgRecordsPerMonth =
DIVIDE([TotalRecords], [DistinctMonths])

Replace 'YourTable' with the actual name of your table. These steps will give you the average number of records per month up to October 31, 2024.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

View solution in original post

1 REPLY 1
saud968
Solution Sage
Solution Sage

To calculate the average number of records per month up to the last completed month in Power BI, you can follow these steps:

Create a new column to extract the month and year from the Created column:
MonthYear = FORMAT('YourTable'[Created], "YYYY-MM")

Create a measure to count the records up to the last completed month:
TotalRecords =
CALCULATE(
COUNT('YourTable'[RecordID]),
'YourTable'[Created] < EOMONTH(TODAY(), -1) + 1
)

Create a measure to count the distinct months up to the last completed month:
DistinctMonths =
CALCULATE(
DISTINCTCOUNT('YourTable'[MonthYear]),
'YourTable'[Created] < EOMONTH(TODAY(), -1) + 1
)

Create a measure to calculate the average number of records per month:
AvgRecordsPerMonth =
DIVIDE([TotalRecords], [DistinctMonths])

Replace 'YourTable' with the actual name of your table. These steps will give you the average number of records per month up to October 31, 2024.

Best Regards
Saud Ansari
If this post helps, please Accept it as a Solution to help other members find it. I appreciate your Kudos!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.