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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
YBZ
Helper III
Helper III

average ignore month

Hi,

 

I want to calculate the Monthly Average cost per year.

 

Currently I have the below :

 

Monthly Average Cost = Divide(sumx('Table','Table[Cost]), distinctcount('Calendar'[Month])).

 

This measure is working. I have however a visual on that page and if you select a speific month, the Monthly Average Cost provides the total cost of that month and divides it by the months in that year. What I would like to see is the Monthly Average of that selected year(s). 

 
I tried the following, 
 
Monthly Average Cost = Calculate(Divide(sumx('Table','Table[Cost]), distinctcount('Calendar'[Month])), all('Table)). 
 
That obviously gives me the total average of all years. But I however do not know how to solve it so that I have a Monthly average per year.
 
Somebody could help me out (I appreciate some explanation to help me get a better understanding for the future) 🙂
 
Regards
 
2 REPLIES 2
DataInsights
Super User
Super User

@YBZ,

 

Try these measures:

 

Total Cost = SUM ( 'Table'[Cost] )

 

Monthly Average Cost =
CALCULATE (
    AVERAGEX ( VALUES ( Calendar[Month] ), [Total Cost] ),
    // clear Calendar filter context
    ALL ( Calendar ),
    // keep the Year filter context from the slicer
    VALUES ( Calendar[Year] )
)

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thanks, but that did not work 

It gives me 0 in the table and when I click on a specif month, it gives me strange values 🙂

 

YBZ_0-1706083331067.png

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.