Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Hello, community,
I have an unusual task to calculate measures in matrix table, that consists of 5 level hierarchy in rows and 3 level hierarchy in columns.
In columns, I have dates-weeks- month. And what I need is when dates are aggregated into week it shows the average
and when rows collapse those averages become sum of averages.
The question how to do calculation that will calculate the SUM of averaes by hierarchy
Solved! Go to Solution.
Hi @yakovlol ,
in the case that @Shivu-2000 solution does not work you can try this....
to show in the value option of your natrix you need to write a measure as follows:
measure sum_average := var tbl = summarize(your_table, the name of column in the row of matrix , "Avg" , average (what you have in you matrix right now) )
return
sumx(tbl,avg)
in this case if you are in the hierarchey level, the sum is the same as average and in top level they would be sum up.
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution to help the other members find it more quickly.
Hi @yakovlol ,
in the case that @Shivu-2000 solution does not work you can try this....
to show in the value option of your natrix you need to write a measure as follows:
measure sum_average := var tbl = summarize(your_table, the name of column in the row of matrix , "Avg" , average (what you have in you matrix right now) )
return
sumx(tbl,avg)
in this case if you are in the hierarchey level, the sum is the same as average and in top level they would be sum up.
If this post helps, then I would appreciate a thumbs up 👍 and mark it as the solution to help the other members find it more quickly.
Hello @Selva-Salimi Thanks for your approach. this is exactly what I need.
But i have another problem, maybe you know how to handle Average measure to calculate with blanks values.
But the real problem is that this blank rows in my table doesn't exist. they are only seen in my matrix table . I used this measure, but seems it doesn't work
Maybe adding zero to sales calculation ([sales] +0) work for you. if not share more details.
If this post helps, then I would appreciate a thumbs up 👍
Hi @yakovlol
So according to my understanding you have a matrix table that have 5-level row hierarchy and a 3-level column hierarchy (dates, weeks, and months), and you want to calculate averages when dates are aggregated to weeks and sums of averages when rows are collapsed (correct??).
To do so firstly you will have to Create Calculated Columns as
Than Create Measures:
Average Value: Create a measure to calculate the average of your desired value. For example:
Average Value = AVERAGE([YourValue])
Sum of Averages: Create a measure to calculate the sum of averages. Use the CALCULATE function to modify the filter context:
Sum of Averages = CALCULATE( [Average Value], ALLEXCEPT(YourTable, YourTable[Week Number]) )
This formula calculates the average value for each week and then sums them up, ignoring the filters applied at the row level.
Configure Matrix Table:
For Example:
If your table has columns Date, Region, Category, Product, Sales, and you want to calculate the average sales per week and the sum of averages per region, you might use the following measures:
Week Number = WEEKNUM([Date]) Month Number = MONTH([Date]) Average Sales = AVERAGE([Sales]) Sum of Average Sales = CALCULATE([Average Sales], ALLEXCEPT(YourTable, YourTable[Week Number]))
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Happy to help!
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
87 | |
87 | |
81 | |
63 | |
49 |
User | Count |
---|---|
121 | |
109 | |
81 | |
67 | |
67 |