Forum Discussion
pg1980
Helper II
3 years agoPercentage Square Matrix (with Total row)
Hi ! I have to be able to make a analysis in a matrix visual. In this analysis I have to sum up the quantity values by “year-month New” and go substracting this number to the total quantity of each ...
- 3 years ago
Hi pg1980
See attached PBIX.
I haven't looked closely at other responses so may be repeating things 🙂
Model:
Month Index is the number of months between New & Out plus 1.
Key measures:
Total Quantity = SUM ( 'YourTable'[Quantity] ) Quantity Out Cumulative by Index = VAR MaxIndex = MAX ( 'Month Index'[Month Index] ) RETURN CALCULATE ( [Total Quantity], 'Month Index'[Month Index] <= MaxIndex, NOT ISBLANK ( 'Month Index'[Month Index] ), REMOVEFILTERS ( 'Month Index' ) ) Total Quantity All Index = CALCULATE ( [Total Quantity], REMOVEFILTERS ( 'Month Index' ) ) Net Quantity Cumulative by Index = [Total Quantity All Index] - [Quantity Out Cumulative by Index] Net Quantity Cumulative by Index Previous = VAR MaxIndex = MAX ( 'Month Index'[Month Index] ) RETURN CALCULATE ( [Net Quantity Cumulative by Index], 'Month Index'[Month Index] = MaxIndex - 1, REMOVEFILTERS ( 'Month Index'[Month Index]) ) Percentage = DIVIDE ( [Net Quantity Cumulative by Index], [Net Quantity Cumulative by Index Previous] )
lbendlin
Super User
3 years agomight as well throw my version into the ring.
pg1980
Helper II
3 years agoHello lbendlin, thanks for your answer but I find a diferent result in the % total row:
In column 2 and 3, the results are diferent:
For column n° 2: 836/980=0,85
For column n° 3: 818/836=0,97
- lbendlin3 years ago
Super User
You can also see that my totals are off by 1. Can we eliminate the July sample data for now?
- pg19803 years ago
Helper II
It's almost there, but the matrix has to repeat the value that doen't have "year-month out"
For example in May ("Year month new") the value 13 has to repeat util the last month.
like this: