Pergunta

I have a basic data set with a ton of slicers that roughly looks like this:

       Hours    SpreadPerHr      Spread
       5.00        5.00          25.00
       10.00       2.00          20.00
       8.00       10.00          80.00

Where Spread is a calculated value where Spread = Hours*SpreadPerHour. The problem is, the totals for these columns follow this formula too, so it looks like this:

       Hours    SpreadPerHr      Spread
       5.00        5.00          25.00
       10.00       2.00          20.00
       8.00       10.00          80.00
Total: 23.00      17.00         391.00

And while the hours total up just fine, SpreadPerHour is dynamic and so Spread is as well. It is incorrect to say Total Spread = Total Hours * Total SpreadPerHour. Totals should be:

Total: 23.00      17.00         125.00 

Is there a way I can make excel leave totals for Hours as-is, but sum the column for Spread instead of multiplying totals?

Foi útil?

Solução

Here is what I think you have in your Power Pivot Model: enter image description here

You have a calculated measure for Spread, which I have labeled SpreadCalc1. The problem with this is that it does the aggregation before it does the multiplication. You need this operation to be done on a row-by-row basis and then aggregated. So instead of a calculated measure, you need to create a calculated column and then sum that column.

enter image description here

The column I have labeled as SpreadCalc has the formula =[Hours] * [SpreadPerHr]. The calculated measure I called Spread is just Sum([SpreadCalc]). You can see there that the total is 125 as desired instead of 391.

Outras dicas

I know this might be a bit redundant now, but I would suggest a slightly different approach.

Adding calculated columns in "small" tables is fine, but it can cause serious performance issues with large databases.

So to solve your problem, I believe the "correct" way is to use SUMX function.

It calculates the expression specifically for each row, which is exactly what you need. And it is smart as far as performance goes (no need to add calculated columns or perform any source-data manipulations).

If you use this formula (correct the name of the table / measures), you should get the desired results:

SUMX(YourTable, [Sum Hour] * [Sum SpreadPerHr])

enter image description here

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top