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
Ritaf
Responsive Resident
Responsive Resident

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
Super User

@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])

Ritaf
Responsive Resident
Responsive Resident

unfortunately, it isn't working...

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.