Question calculated field pivot table

martijnzi

New Member
Joined
Jul 3, 2019
Messages
6
Hello,

I have a question. I would like to calculated ratio's from a database with balancesheets in a pivot-table. The data is as follows:

CompanyBalance Sheet noDescriptionValueYear
Apple3Cash252018
Apple4Inventories352018
Apple5Short Term debt752018
Facebook3Cash202018
Facebook4Inventories212018
Facebook5Short Term debt402018
Apple3Cash1002017
Apple4Inventories802017
Apple5Short Term debt502017
Facebook3Cash602017
Facebook4Inventories182017
Facebook5Short Term debt202017

<tbody>
</tbody>


What I would like is to have a calculated field in a pivot table that calculates the ratio Cash / Short Term Debt, like this: This is what the result should be:

company20172018
Apple 2,000 0,333
Facebook 3,000 0,500

<tbody>
</tbody>

I have been able to create this pivot-table myself, but I had to use a work around. I added two columns to the data, like this:

CompanyBalance Sheet noDescriptionValueYearCashShort Term Debt
Apple3Cash25201825
Apple4Inventories352018
Apple5Short Term debt75201875
Facebook3Cash20201820
Facebook4Inventories212018
Facebook5Short Term debt40201840
Apple3Cash1002017100
Apple4Inventories802017
Apple5Short Term debt50201750
Facebook3Cash60201760
Facebook4Inventories182017
Facebook5Short Term debt20201720

<tbody>
</tbody>

Then I was able to use a calculated field: = Cash / Short term debt. The result is shown above.

However I am looking for a way to calculate this without changing the data set, because the real dataset is huge and I want to calculate many different ratio's. I need flexibility. I hope anyone has a solution :).

I hope the problem definition is clear :)

Kind regards,
Martijn

 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
you mean something like this?

Source:

CompanyBalance Sheet noDescriptionValueYear
Apple3Cash252018
Apple4Inventories352018
Apple5Short Term debt752018
Facebook3Cash202018
Facebook4Inventories212018
Facebook5Short Term debt402018
Apple3Cash1002017
Apple4Inventories802017
Apple5Short Term debt502017
Facebook3Cash602017
Facebook4Inventories182017
Facebook5Short Term debt202017
PivotTable:

YearValues
2017
2018
Company Ratio1 Ratio2 Ratio1 Ratio2
Apple
2.00​
1.60​
0.33​
0.47​
Facebook
3.00​
0.90​
0.50​
0.53​
Ratio1: Cash / Short Term Debt
Ratio2: Cash / Inventories
 
Last edited:
Upvote 0
Hey Sandy666,

That looks perfect! that is what I need :). How did you do it? And would it also be possible to calculate: (Cash + Inventories) / Short term debt?

BTW, I think you used another definition for ratio 2: Inventories / Short Term Debt.
 
Upvote 0
you are right with Ratio2 :)

YearValues
2017
2018
Company Ratio1 Ratio2 Ratio3 Ratio1 Ratio2 Ratio3
Apple
2.00​
1.60​
3.6​
0.33​
0.47​
0.8​
Facebook
3.00​
0.90​
3.9​
0.50​
0.53​
1.025​

I used PowerQuery

Code:
[SIZE=1]// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Pivot = Table.Pivot(Source, List.Distinct(Source[Description]), "Description", "Value", List.Sum)
in
    Pivot[/SIZE]

Query-Table, not visible in the sheet:
CompanyBalance Sheet noYearCashInventoriesShort Term debt
Apple
3​
2017​
100​
nullnull
Apple
3​
2018​
25​
nullnull
Apple
4​
2017​
null
80​
null
Apple
4​
2018​
null
35​
null
Apple
5​
2017​
nullnull
50​
Apple
5​
2018​
nullnull
75​
Facebook
3​
2017​
60​
nullnull
Facebook
3​
2018​
20​
nullnull
Facebook
4​
2017​
null
18​
null
Facebook
4​
2018​
null
21​
null
Facebook
5​
2017​
nullnull
20​
Facebook
5​
2018​
nullnull
40​

and created result PivotTable from Query-Table with three Calculated Fields
 
Last edited:
Upvote 0
Hey Sandy,

That looks exactly like what I want. And also, it does exactly the same as the work around. Also, it suggests there is not a more straight forward way to calculate those fields within the standard pivot-table manues.

Now here is the issue, I will use the database for professional issues. I couldnt install power query, because installations are impossible if you are a "user" of a computer in this company(I use office 2010). Do you think there is a way, which doesn't require the installation of applications? Since I work in a large company I think it will be unlikely that the ICT department will install it.

I hope you have more wisdom :)

Kind regards,
Martijn
 
Upvote 0
Hey Sandy,

Somebody told me here we can also access accel 2016! So the problem should be sovled (i read that it is integrated in there)!

Ill keep you updated if i have my final solution :)
 
Upvote 0
I wonder why IT departments allow for dangerous vba and do not allow PQ. PQ can not destroy anything but vba yes :LOL:
 
Upvote 0
Problem is solved now. I explored the power query tool and I realized it is brilliant. Thanks so much!!
 
Upvote 0
You are welcome :)

If you are happy you can hit Thanks/Like button at the bottom left corner in the post(s) which helped you

Have a nice day
 
Upvote 0

Forum statistics

Threads
1,214,405
Messages
6,119,323
Members
448,887
Latest member
AirOliver

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