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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
sgeorge930
Regular Visitor

Average by months excluding current month

My brain has not been working properly when thinking of DAX, any advice would be appreciated.

 

I would like to create a measure to calculate the average number of credits used per month excluding the current month.

For example: 

DateCredits used
12/15/20225
12/17/20227
1/6/20239
2/4/20234

 

So then it would need to summerize by month and then average per month excluding February as the current month. 

The result would be: 10.5 credits used on average per month (excluding current month)

 

There must be an easy way to write this in DAX, I just have been annoyingly stuck on this fairlyy simple one.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@sgeorge930 , prefer to use a date table joined date of you table having month year

calculate(

Averagex(Values(Date[Month Year]), calculate(Sum(Table[Credit Used])) ) , filter(all(Date), eomonth(date[Date],0) <> eomonth(today(),0) ) )

 

 

to get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
FreemanZ
Super User
Super User

hi @sgeorge930 

1) try to add a column like:

Month = FORMAT([Date], "YYYYMM")

2) write a measure like:

Measure = 
AVERAGEX(
   CALCULATETABLE(
       VALUES(TableName[Month]),
       TableName[Month] < FORMAT(TODAY(), "YYYYMM")
   ),
    CALCULATE(SUM(TableName[Credits]))
)

it worked like:

FreemanZ_1-1676695759187.png

 

 

 

amitchandak
Super User
Super User

@sgeorge930 , prefer to use a date table joined date of you table having month year

calculate(

Averagex(Values(Date[Month Year]), calculate(Sum(Table[Credit Used])) ) , filter(all(Date), eomonth(date[Date],0) <> eomonth(today(),0) ) )

 

 

to get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.