Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredGet Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more
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.
Below is my workbook where data's from.
Thank you guys.
Solved! Go to Solution.
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:
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.
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 @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:
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.
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.
Would you please help me with above again.
Thank you in advance!
That really works! Thank you so much!
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
Proud to be a Super User!
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
Check out the October 2025 Power BI update to learn about new features.