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
brumero
Helper I
Helper I

Compare Total per month vs average per month per year

Hi, 

 

I'm trying to generate a report in Power BI, showing in a chart the total expenditures per month against the average per month per year of the same measure. I have done this report before in Microstrategy, now I want to have the same in Power BI.

 

This should be the final chart. To have in mind, there is a slicer in the report, selecting certain years. 

monthly average.png

1 ACCEPTED SOLUTION

Sorry, @brumero - my mistake, I meant:

 

Average Measure = 
  VAR __Year = MAX('Table'[Year])
  VAR __Table = 
      SUMMARIZE(
        FILTER(ALL('Table'),[Year] = __Year),
        [Month],
        "__Value",SUM('Table'[Value])
      )
RETURN
  AVERAGEX(__Table,[__Value])

It's the littlest things...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@brumero ,

try like

Averagex(Summarize(Filter(Table,Table[Year]=max(Table[year])),Table[Month],table[Year],"_sum",sum(Table[Value])),[_sum])

Thank you @amitchandak , but unfortunately I got the same result:

avgyr.jpg

Sorry, @brumero - my mistake, I meant:

 

Average Measure = 
  VAR __Year = MAX('Table'[Year])
  VAR __Table = 
      SUMMARIZE(
        FILTER(ALL('Table'),[Year] = __Year),
        [Month],
        "__Value",SUM('Table'[Value])
      )
RETURN
  AVERAGEX(__Table,[__Value])

It's the littlest things...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thank you @Greg_Deckler.

Works perfectly

 

 

Sorry about that, I knew I needed an all in there but apparently on my first go just forgot to include it!! Glad we got there!

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

So the average would be something like:

 

Average Measure = 
  VAR __Year = MAX('Table'[Year])
  VAR __Table = 
      SUMMARIZE(
        FILTER('Table',[Year] = __Year),
        [Month],
        "__Value",SUM('Table'[Value])
      )
RETURN
  AVERAGEX(__Table,[__Value])

 

Use a column/line chart. Your final chart will look a little different than that in Power BI.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Thanks @Greg_Deckler ,

 

I'd tried but I get the same result as other methods. Let me show you.

 

avgyr.jpg

$ Prom Año = 
  VAR __Year = MAX('01 Fecha'[Fecha].[Year])
  VAR __Table = 
      SUMMARIZE(
        FILTER('01 Fecha',[Year] = __Year),
        [Month],
        "__Value",SUM('05 Mayor PA'[Gasto U$D])
      )
RETURN
  AVERAGEX(__Table,[__Value])

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.