Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
nc
 
Posts: n/a
Default Pivot table using External data

Hi

I am generating a pivot table using the following query

SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
REG$'` `'1100 REG$'`
UNION
SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
REG$'` `'1157 REG$'`
UNION
SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
REG$'` `'1165 REG$'`

The problem I am having is that I am getting a difference in the total
amount when the same query is generated individually for 1100 REG, 1157 REG
and 1165REG and aggregated. Why?

  #2   Report Post  
Debra Dalgleish
 
Posts: n/a
Default

Try UNION ALL instead of UNION.

nc wrote:
Hi

I am generating a pivot table using the following query

SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
REG$'` `'1100 REG$'`
UNION
SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
REG$'` `'1157 REG$'`
UNION
SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
REG$'` `'1165 REG$'`

The problem I am having is that I am getting a difference in the total
amount when the same query is generated individually for 1100 REG, 1157 REG
and 1165REG and aggregated. Why?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

  #3   Report Post  
nc
 
Posts: n/a
Default

Hi Debra

Thanks, it works. What is the differene between the two?

"Debra Dalgleish" wrote:

Try UNION ALL instead of UNION.

nc wrote:
Hi

I am generating a pivot table using the following query

SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
REG$'` `'1100 REG$'`
UNION
SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
REG$'` `'1157 REG$'`
UNION
SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
REG$'` `'1165 REG$'`

The problem I am having is that I am getting a difference in the total
amount when the same query is generated individually for 1100 REG, 1157 REG
and 1165REG and aggregated. Why?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html


  #4   Report Post  
Debra Dalgleish
 
Posts: n/a
Default

By default, UNION excludes duplicate records. UNION ALL retains the
duplicate values.

nc wrote:
Hi Debra

Thanks, it works. What is the differene between the two?

"Debra Dalgleish" wrote:


Try UNION ALL instead of UNION.

nc wrote:

Hi

I am generating a pivot table using the following query

SELECT `'1100 REG$'`.`Ap/ArID`, `'1100 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1100
REG$'` `'1100 REG$'`
UNION
SELECT `'1157 REG$'`.`Ap/ArID`, `'1157 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1157
REG$'` `'1157 REG$'`
UNION
SELECT `'1165 REG$'`.`Ap/ArID`, `'1165 REG$'`.Amount
FROM `F:\Finance\Income Reconciliation\2004-05\GL transactions 0405`.`'1165
REG$'` `'1165 REG$'`

The problem I am having is that I am getting a difference in the total
amount when the same query is generated individually for 1100 REG, 1157 REG
and 1165REG and aggregated. Why?



--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html





--
Debra Dalgleish
Excel FAQ, Tips & Book List
http://www.contextures.com/tiptech.html

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
grouping data in a pivot table William Excel Discussion (Misc queries) 2 April 6th 05 09:16 PM
HOw do I display text in the data field of the pivot table, inste. Zoltan Excel Worksheet Functions 1 March 2nd 05 06:21 PM
I am having problems creating pivot table of data wyman Charts and Charting in Excel 1 January 12th 05 05:17 PM
Using Microsoft Query data in a pivot table. slapana Charts and Charting in Excel 0 January 11th 05 05:03 PM
Pivot Table - Group by Month - Show Items with no data Dan Reynolds Excel Discussion (Misc queries) 0 November 28th 04 01:01 AM


All times are GMT +1. The time now is 11:06 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"