# Getpivotdata() with several elements for each field

#### reitan

##### New Member
I have some excel pivottable connected to a cube. The data are further used in excel by the getpivotdata() formula.

In the example below I have combined two getpivotdata() formulas to calculate the Budget variance. As you see the only difference of the "budget" and the "actuals" are the last element. "[Set].&[02.BGT]" vs "[Set].&[01.ACT]").

EXAMPLE:
Actuals =getpivotdata("[Measures].[Amount]";\$A\$6;"[TimeByYM]";"[TimeByYM].[Alle Måneder]";"[Set]";"[Set].&[01.ACT]")

Budget =getpivotdata("[Measures].[Amount]";\$A\$6;"[TimeByYM]";"[TimeByYM].[Alle Måneder]";"[Set]";"[Set].&[02.BGT]")

Budget variance =getpivotdata("[Measures].[Amount]";\$A\$6;"[TimeByYM]";"[TimeByYM].[Alle Måneder]";"[Set]";"[Set].&[01.ACT]") - getpivotdata("[Measures].[Amount]";\$A\$6;"[TimeByYM]";"[TimeByYM].[Alle Måneder]";"[Set]";"[Set].&[02.BGT]")

In more complex cases when I have to use 6-10 getpivotdata() formulas it is very difficult to read and maintain the formulas and mistakes may be done.

My Question:
=> Is it possible to make the formula shorter by using ony one getpivotdata() to get the budget variance?

For instance somthing like this?

=getpivotdata(....;;;;;"[Set].&[01.ACT] - [Set].&[02.BGT]")

in other cases I would like the sum of two departments wich are not grouped in the cube structure...
=getpivotdata(....;;;;;"[department].&[21] - [department].&[39]")

is this possible?

### Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

Replies
0
Views
149
Replies
5
Views
129
Replies
1
Views
404
Replies
2
Views
402
Replies
2
Views
128

1,190,637
Messages
5,982,068
Members
439,753
Latest member
mnyankee

### 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?

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