cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Ritaf
Post Patron
Post Patron

Average of count measure, by month and category include sum in total

Hi all, I need to calculate a monthly average of counting, by category and need to sum the averages as Total. I used a dax script below and it works great except a total. How can I fix it to get a sum of averages in a total row? Thanks in advance, Rita AVG_Count_Per_month =

AVERAGEX (

SUMMARIZE ( Table1, Table1[month-year], Table1[category], "Count", COUNT ( Table1[id] ) ), [Count] )

3 REPLIES 3
v-yangliu-msft
Community Support
Community Support

Hi  @Ritaf ,

According to your description, I created some data to show:

v-yangliu-msft_0-1605606039327.jpeg

 

 

Here are the steps you can follow:

1. Create calculcated column.

Month = MONTH('Table'[Date])
Column = CALCULATE(AVERAGE('Table'[amount]),ALLEXCEPT('Table','Table'[Month]))

2. Create Measure.

Measure 2 =
var tt=SUMMARIZE('Table','Table'[Month],"avg_amount",CALCULATE(AVERAGE('Table'[amount])))
return
IF(HASONEVALUE('Table'[Month]),MAX('Table'[Column]),SUMX(tt,[avg_amount]))

3. Result.

v-yangliu-msft_1-1605606039360.jpeg

You can downloaded PBIX file from here.

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User IV
Super User IV

@Ritaf , Try if this can work

AVG_Count_Per_month =
var _tab = SUMMARIZE ( Table1, Table1[month-year], Table1[category], "Count", COUNT ( Table1[category] ) )
return
sumx(summarize(_tab,[month-year], "_1", average([Count])),[_1])



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

unfortunately, it isn't working...

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

April Update

Check it Out!

Click here to read more about the April 2021 Updates!

secondImage

The largest Power BI virtual conference

100+ sessions, 100+ speakers, Product managers, MVPs, and experts. All about Power BI. Attend online or watch the recordings.

secondImage

Experience what’s next for Power BI

See the latest Power BI innovations, updates, and demos from the Microsoft Business Applications Launch Event.