Pivot Tables

Isabella

Well-known Member
Joined
Nov 7, 2008
Messages
643
Hi,

Could someone please show me how i can perform a pivot table that will give me the same result as show in Col J-P. I want to avoid using formula if possible.

Excel Workbook
ABCDEFGHIJKLMNOP
42-2930-59
5TypeAmountCCYAgeSourceCCYRateSourceNo. of itemsValue (AUD)ABS (AUD)No. of itemsValue (AUD)ABS (AUD)
6SCR8268.57AUD15Team1AUD1Team1329,268.5729268.57
7SCR20000AUD20Team1EUR0.75581Team216,844.946844.94067
8SCR1000AUD5Team1GBP0.645411Team300.000
9SCR4417.8GBP7Team2JPY82.56223Team41729,314.601803231.35
10SCR2208.9GBP30Team2USD1.00655
11SCR100000AUD40Team3
12LCR1163.22EUR12Team4
13LDR-3320.14EUR39Team4
14LCR9646.51EUR15Team4
15LDR-12618.8EUR40Team4
16LCR476017.8EUR15Team4
17LDR-1688137JPY38Team4
18LCR7187517JPY4Team4
19LDR-6303971JPY15Team4
20LCR108431.3USD15Team4
21LCR15652.36USD15Team4
22LDR-280467USD17Team4
23LCR52025.14USD17Team4
24LCR7589.03USD17Team4
25LCR1965.98EUR3Team4
26LDR-98555.5EUR17Team4
27LDR-33658.3EUR17Team4
28LDR-19670EUR10Team4
29LDR-247310EUR17Team4
30LDR-2068.46EUR13Team4
31LDR-800EUR28Team4
Sheet1
 
Ok, i think i am getting somewhere now.

I got to the part where i have 2 boxes in the Query Wizard, in the first box is Forex and Maintable, i click the headings i need for each named range by using the right arrow key to move them into the second box, i then press OK. Is this what yuo got?

I got a message "The Query Wizard can not continue because it cannot join the tables in your query. You must join the tables manually in Micorsoft Query by dragging the fields to joint between the tables


OK, Isabella. Thanks for clarifying the steps. I don't have Excel 2010, sorry.


FWIW, prior to Excel 2007 the steps are,
  • ALT-D-P to start pivot table wizard
  • choose "External data source", Next
  • Get Data...
  • from the Databases strip, "Excel files*", OK
  • then follow wizard to the end & take the option to edit in MS Query
This might help you to work out the steps in Excel 2010. Suggest you refer to the help files. Maybe google the Microsoft site?

regards
 
Upvote 0

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
YES, Isabella. :) Keep going.

You can continue from there, or you can just choose data from one table. It doesn't matter what you do, because when you get to MS Query you edit the SQL to change it anyway.
 
Upvote 0
YES, Isabella. :) Keep going.

You can continue from there, or you can just choose data from one table. It doesn't matter what you do, because when you get to MS Query you edit the SQL to change it anyway.

Fazza, i need the SQL to produce data similar to J-P, Where i have age criteria breaks for each team so you can see in row 4 i have 2-29 and then 30-59 and it will go up to 120 days, the values in Col L and O etc will be converted to AUD based on the rates in G-H.

I found how to get 2010 working, so i've learn something new thats for sure.

Excel Workbook
ABCDEFGHIJKLMNOP
42-2930-59
5TypeAmountCCYAgeSourceCCYRateSourceNo. of itemsValue (AUD)ABS (AUD)No. of itemsValue (AUD)ABS (AUD)
6SCR8268.57AUD15Team1AUD1Team1329,268.5729268.57
7SCR20000AUD20Team1EUR0.75581Team216,844.946844.941
8SCR1000AUD5Team1GBP0.645411Team3000
9SCR4417.8GBP7Team2JPY82.56223Team41729,314.601803231
10SCR2208.9GBP30Team2USD1.00655
11SCR100000AUD40Team3
12LCR1163.22EUR12Team4
13LDR-3320.14EUR39Team4
14LCR9646.51EUR15Team4
15LDR-12618.8EUR40Team4
16LCR476017.8EUR15Team4
17LDR-1688137JPY38Team4
18LCR7187517JPY4Team4
19LDR-6303971JPY15Team4
20LCR108431.3USD15Team4
21LCR15652.36USD15Team4
22LDR-280467USD17Team4
23LCR52025.14USD17Team4
24LCR7589.03USD17Team4
25LCR1965.98EUR3Team4
26LDR-98555.5EUR17Team4
27LDR-33658.3EUR17Team4
28LDR-19670EUR10Team4
29LDR-247310EUR17Team4
30LDR-2068.46EUR13Team4
31LDR-800EUR28Team4
Sheet2
 
Upvote 0
Good work, Isabella.

Include the Age field in the pivot table and then 'group' on that field to achieve the different age brackets. This is normal pivot table functionality. Here is an on-line description http://www.contextures.com/xlpivot07.html, from a site that has lots of other good info on pivot tables.

regards
 
Upvote 0
PS

If you joined both tables - the one I called MainData and the Forex - in the SQL en route to creating the pivot table, you should already all amounts in AUD. The conversion to AUD was done by the SQL. Are you OK with that conversion?

F
 
Upvote 0
PS

If you joined both tables - the one I called MainData and the Forex - in the SQL en route to creating the pivot table, you should already all amounts in AUD. The conversion to AUD was done by the SQL. Are you OK with that conversion?

F

Fazza i am loving this SQL, i amended the SQL to include M.Age before M.Source, i then opened Via pivot table. Couple of questions though.

1.How would i get the ABS for each age bracket similar to my example i shown for 2-29 bracket

2. My raw data is not fixed so everyday the raw data will change ranges , the header row will remain the same though, the name range must change to suit.

3. I need this pivot in the same workbook where my rata is so in sheet 3 as example
 
Upvote 0
Good morning, Isabella.

To get the absolute values, create another field within the SQL and then sum on it in the pivot table, as a datafield. Such as.
Code:
SELECT M.Amount/F.Rate AS [Value], M.Age, M.Source, ABS(M.Amount/F.Rate) AS [AbsValue]
FROM Forex F, MainData M
WHERE F.CCY = M.CCY

As the data changes each day, change the named range MainData to suit. So if today it covers A5:E31 and tomorrow A5:E1234, edit the named range to suit. Such as via CTRL-F3, select MainData and edit directly in the "refers to" box. It might help to use the F2 key when editing? Or have some VBA update the range each time,
range("A5").currentregion.name = "MainData"

You could have VBA do all the work each day to accommodate changing data. It is little more than change the extent of the named range and then refresh the pivot table.

Move the worksheet containing the pivot table into the workbook you want it in.

:)
 
Upvote 0
Hi Fazza

I think i am getting close to what i want.

1. With the pivot table when i Click on Group i selected Begin with 2 and end with 120, but i cannot get 2-29, 30-59, 60-89, 90-119, >120,

2. How do i get the Count of Age Field next to the source because when i move the Age to Row it remove my Age brackets from Column field,

I want a layout similar to this.

<TABLE style="WIDTH: 462pt; BORDER-COLLAPSE: collapse" cellSpacing=0 cellPadding=0 width=616 border=0 x:str><COLGROUP><COL style="WIDTH: 66pt; mso-width-source: userset; mso-width-alt: 3218" span=7 width=88><TBODY><TR style="HEIGHT: 12.75pt" height=17><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 66pt; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" width=88 height=17> </TD><TD class=xl23 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 198pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent" width=264 colSpan=3 x:str="'2-29">2-29</TD><TD class=xl23 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext 0.5pt solid; BORDER-LEFT: windowtext; WIDTH: 198pt; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent" width=264 colSpan=3 x:str="'3-59">3-59</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17 x:str="Source ">Source </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent">Age Count</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent">Value</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent">AbsValue</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent">Age Count</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent">Value</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent">AbsValue</TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>Team1</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>Team2</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD></TR><TR style="HEIGHT: 12.75pt" height=17><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext 0.5pt solid; BORDER-BOTTOM: windowtext 0.5pt solid; HEIGHT: 12.75pt; BACKGROUND-COLOR: transparent" height=17>Team3</TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD><TD class=xl22 style="BORDER-RIGHT: windowtext 0.5pt solid; BORDER-TOP: windowtext; BORDER-LEFT: windowtext; BORDER-BOTTOM: windowtext 0.5pt solid; BACKGROUND-COLOR: transparent"> </TD></TR></TBODY></TABLE>





Good morning, Isabella.
To get the absolute values, create another field within the SQL and then sum on it in the pivot table, as a datafield. Such as.
Code:
SELECT M.Amount/F.Rate AS [Value], M.Age, M.Source, ABS(M.Amount/F.Rate) AS [AbsValue]
FROM Forex F, MainData M
WHERE F.CCY = M.CCY

As the data changes each day, change the named range MainData to suit. So if today it covers A5:E31 and tomorrow A5:E1234, edit the named range to suit. Such as via CTRL-F3, select MainData and edit directly in the "refers to" box. It might help to use the F2 key when editing? Or have some VBA update the range each time,
range("A5").currentregion.name = "MainData"

You could have VBA do all the work each day to accommodate changing data. It is little more than change the extent of the named range and then refresh the pivot table.

Move the worksheet containing the pivot table into the workbook you want it in.

:)
 
Upvote 0
For the grouping, try from 0 to 120 by 30. Gives 0-29, 30-59, 60-89, 90-120, >120.

Put the field in twice. Once as a datafield & once as a row field. (I counted the Source field, btw.)

OK?
 
Upvote 0
For the grouping, try from 0 to 120 by 30. Gives 0-29, 30-59, 60-89, 90-120, >120.

Put the field in twice. Once as a datafield & once as a row field. (I counted the Source field, btw.)

OK?

Fazza, the grouping looks right now but the Age count and Abs value does not look right, my field setting is this, the issue is with Age count and AbsValue

Row = Source
Column = Age

Data= Sum of Value
= Sum of AbsValues
=Age Count
 
Upvote 0

Forum statistics

Threads
1,217,371
Messages
6,136,170
Members
449,996
Latest member
duraichandra

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