Sum for group in table

farsider

New Member
Joined
Sep 6, 2010
Messages
44
I have a spreadsheet with a column that calculates the total for each key group and returns that total on each line of that column. I've use a array formula and this works well (slow), but now I'd like to do this in a column on PowerPivot.

I've been able to do this in series of measures, however I really need this in the table column. Example of working spreadsheet.

Sheet1

*ABC
keyunitstotal
x
x
x
x
y
y
y
z
z
z
z

<tbody>
[TD="bgcolor: #cacaca, align: center"]1[/TD]

[TD="bgcolor: #cacaca, align: center"]2[/TD]

[TD="align: right"]3[/TD]
[TD="align: right"]5[/TD]

[TD="bgcolor: #cacaca, align: center"]3[/TD]

[TD="align: right"]2[/TD]
[TD="align: right"]5[/TD]

[TD="bgcolor: #cacaca, align: center"]4[/TD]

[TD="align: right"]-2[/TD]
[TD="align: right"]5[/TD]

[TD="bgcolor: #cacaca, align: center"]5[/TD]

[TD="align: right"]2[/TD]
[TD="align: right"]5[/TD]

[TD="bgcolor: #cacaca, align: center"]6[/TD]

[TD="align: right"]10[/TD]
[TD="align: right"]20[/TD]

[TD="bgcolor: #cacaca, align: center"]7[/TD]

[TD="align: right"]-5[/TD]
[TD="align: right"]20[/TD]

[TD="bgcolor: #cacaca, align: center"]8[/TD]

[TD="align: right"]15[/TD]
[TD="align: right"]20[/TD]

[TD="bgcolor: #cacaca, align: center"]9[/TD]

[TD="align: right"]100[/TD]
[TD="align: right"]0[/TD]

[TD="bgcolor: #cacaca, align: center"]10[/TD]

[TD="align: right"]50[/TD]
[TD="align: right"]0[/TD]

[TD="bgcolor: #cacaca, align: center"]11[/TD]

[TD="align: right"]-75[/TD]
[TD="align: right"]0[/TD]

[TD="bgcolor: #cacaca, align: center"]12[/TD]

[TD="align: right"]-75[/TD]
[TD="align: right"]0[/TD]

</tbody>

Spreadsheet Formulas
CellFormula
C2{=ROUND(SUM(IF($A2=INDIRECT("$a$2:$a$"&COUNTA(A:A)),INDIRECT("$b$2:$b$"&COUNTA(A:A)))),0)}

<tbody>
</tbody>

<tbody>
</tbody>

This formula is copied down the total column.

I've tried many different DAX formulas:

=CALCULATE(SUM([units]),[key]="Z", all(Data)) - this works for a single key

=CALCULATE(SUMx(data,Data[units]),DISTINCT(Data[key])) - not working.

Thanks
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
Thanks StrafeXL - that's exactly what I needed. Also the link looks like a great source for PowerPivot.

Much appreciated :)
 
Upvote 0

Forum statistics

Threads
1,223,958
Messages
6,175,628
Members
452,661
Latest member
Nonhle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top