Forum Discussion
LeoLi
1 year agoFrequent 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 month...
- Anonymous1 year ago
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 ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
ryan_mayu
Super User
1 year agowhat 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