Forum Discussion
Percentajes in a matrix
- 2 years ago
Hi ancamar ,
It seems like you have created a calculated column for calculating the percentages. Since calculated columns work on row context (current row), hence you are getting correct percentages for each row, but incorrect values at sub-total levels. It is simply summing up the percentage values in each row.
You can solve this problem by creating a calculated measure instead.
For example - the following shows the sample dataset I created (based on your data)
The below matrix visual compares the output of consumption percentage calculated via calculated column and measure. You will get the results you were looking for in the field Consumption Percentage Measure.
The measure created is as follows -
Consumption Percentage Measure = CALCULATE(SUM('Table'[Consumed])/SUM('Table'[Limit]))CALCULATE function helps with filter context. For each individual row, we are getting the correct percentage. At the level of Company sub-total, the values are summed up and then the percentage is calculated, as per the formula.
You can understand the difference between the outputs of using calculated columns and measures by seeing them side-by-side as shown in the matrix above.
I hope it's the output you were looking for!
Hi ancamar ,
It seems like you have created a calculated column for calculating the percentages. Since calculated columns work on row context (current row), hence you are getting correct percentages for each row, but incorrect values at sub-total levels. It is simply summing up the percentage values in each row.
You can solve this problem by creating a calculated measure instead.
For example - the following shows the sample dataset I created (based on your data)
The below matrix visual compares the output of consumption percentage calculated via calculated column and measure. You will get the results you were looking for in the field Consumption Percentage Measure.
The measure created is as follows -
CALCULATE function helps with filter context. For each individual row, we are getting the correct percentage. At the level of Company sub-total, the values are summed up and then the percentage is calculated, as per the formula.
You can understand the difference between the outputs of using calculated columns and measures by seeing them side-by-side as shown in the matrix above.
I hope it's the output you were looking for!
- ancamar2 years agoFrequent Visitor
Wow, that worked flawlessly! It was as simple as that. You saved me!
Thank you very much!
Have a nice weekend!!!