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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
LeoLi
Frequent Visitor

Monthly Average in Matrix

Hello, i am new to Power BI and i am looking for help.

 

I would like to build a matrix, rows are dates(month and day) and columns are error types.

 

This is the best i can do but only have monthly subtotal setup. i would like to add monthly average to it, right below the monthly total.

LeoLi_1-1726174397659.png

 

Below is my workbook where data's from.

LeoLi_0-1726174149042.png

Thank you guys.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @LeoLi ,

 

Here I suggest you to create a DimDate Table and a Level Table contains Days and "Sum", "Average" in it.

DimDate = ADDCOLUMNS(CALENDARAUTO(),"YearMonth",YEAR([Date]) * 100 + MONTH([Date]),"MonthNum",MONTH([Date]),"Month",FORMAT([Date],"MMMM"),"Day",DAY([Date]),"DayKey",FORMAT(DAY([Date]),"00"))
Level2 = 
UNION(DISTINCT(SELECTCOLUMNS(DimDate,"Value",FORMAT([Day],"00"))),{"Sum","Average"})

Relationship:

vrzhoumsft_0-1726208952174.png

Measures:

Count Error = CALCULATE(COUNT('Table'[Error Type]))
Measure 2 = 
VAR _DAY = CALCULATE(COUNT('Table'[Error Type]),FILTER(DimDate,DimDate[DayKey] = MAX(Level2[Value])))
VAR _SUM = [Count Error]
VAR _AVERAGE = AVERAGEX(VALUES(DimDate[Day]),[Count Error])
RETURN
SWITCH(MAX(Level2[Value]),"SUM", _SUM,"Average", _AVERAGE,_DAY)

Result is as below.

vrzhoumsft_1-1726208994638.png

 

Best Regards,
Rico Zhou

 

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

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @LeoLi ,

 

Here I suggest you to create a DimDate Table and a Level Table contains Days and "Sum", "Average" in it.

DimDate = ADDCOLUMNS(CALENDARAUTO(),"YearMonth",YEAR([Date]) * 100 + MONTH([Date]),"MonthNum",MONTH([Date]),"Month",FORMAT([Date],"MMMM"),"Day",DAY([Date]),"DayKey",FORMAT(DAY([Date]),"00"))
Level2 = 
UNION(DISTINCT(SELECTCOLUMNS(DimDate,"Value",FORMAT([Day],"00"))),{"Sum","Average"})

Relationship:

vrzhoumsft_0-1726208952174.png

Measures:

Count Error = CALCULATE(COUNT('Table'[Error Type]))
Measure 2 = 
VAR _DAY = CALCULATE(COUNT('Table'[Error Type]),FILTER(DimDate,DimDate[DayKey] = MAX(Level2[Value])))
VAR _SUM = [Count Error]
VAR _AVERAGE = AVERAGEX(VALUES(DimDate[Day]),[Count Error])
RETURN
SWITCH(MAX(Level2[Value]),"SUM", _SUM,"Average", _AVERAGE,_DAY)

Result is as below.

vrzhoumsft_1-1726208994638.png

 

Best Regards,
Rico Zhou

 

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

 

Hi @Anonymous , Thank you for your previous answer that really helps me a lot.

However, i have a further question about the average. I would like to put weekends data in the dashboard but i want them only counted in sum, not in average. To better describe this case, pls see in screenshot. for Aug's data, I would like to divide sum only by 2 days (not including aug 31st). So the highlighted 115 would be 346/2=173. And also for Aug 30th, there is one error not showing up so the average of that error becomes 9/1=1, which i hope it would be 9/2=4.5.
The way to decide if the date should be included when counting the average could be the total error numbers of that day is higher than 20.

LeoLi_0-1726778494387.png

 


Would you please help me with above again.

Thank you in advance!

That really works! Thank you so much!

ryan_mayu
Super User
Super User

what do mean that column are error types? pls provide the output that based on the sample data you provide. That will be easier for us to understand the calculation logic. 

What's more , pls paste your sample data in your post,not the screenshot





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

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors