#1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default pivottable

I have vba code that creates a pivottable with an
external informix database as the source.
Part of the SQL statement is listed below:

SELECT loc_id, ........
invt_mthend_qty*invt_avg_cost

FROM informix.grp_name grp_name......

WHERE item.item_grp_nbr = grp_name.grp_nbr ......

When the code attempts to calculate the pivottable, the field
"inv_total.invt_mthend_qty*invt_avg_cost" is
inconsistently displayed as
inv_total.invt_mthend_qty*invt_avg_cost
OR EXPR.

Any thoughts on why the reference is not consistent?

Thanks

Fred

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 593
Default pivottable

"Fred" wrote ...

I have vba code that creates a pivottable with an
external informix database as the source.
Part of the SQL statement is listed below:

SELECT loc_id, ........
invt_mthend_qty*invt_avg_cost

FROM informix.grp_name grp_name......

WHERE item.item_grp_nbr = grp_name.grp_nbr ......

When the code attempts to calculate the pivottable, the field
"inv_total.invt_mthend_qty*invt_avg_cost" is
inconsistently displayed as
inv_total.invt_mthend_qty*invt_avg_cost
OR EXPR.

Any thoughts on why the reference is not consistent?


Consider this:

SELECT ColumnA * ColumnB

It is an expression using two columns, rather than a column in its own
right. It doesn't have a name but needs one: each column in the
results set must have a unique name so it can be identified and
distinguished. You haven't given it a name so the data provider has
done it for you, I guess by using the expression text or EXPR, EXPR1,
EXPR2 etc when the expression is too long or not unique.

Why the naming convention is inconsistent, I cannot speculate.
However, if you give the expression an explicit name, I assume it will
always be consistent. To give the expression a name, use an alias. You
did so with your table names

FROM informix.grp_name grp_name

which can be more clearly written as

FROM informix.grp_name AS grp_name

Hence, use something like:

SELECT invt_mthend_qty*invt_avg_cost AS total_mth_yield

using a meaningful alias, of course.

Jamie.

--
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 90
Default pivottable

Thankyou Jamie.

I successfully made the changes with the AS statement.

I have modified the code a couple of times using
inv_total.invt_mthend_qty*invt_avg_cost or EXPR as the field, when the code
would error out.

Hopefully the AS statement resolves it and I don't have to guess if it will
work this time or the next.




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
PivotTable ausstone Charts and Charting in Excel 0 August 4th 10 05:38 PM
Creating a PivotTable w/o selecting data in an existing PivotTable Damian Excel Discussion (Misc queries) 6 November 2nd 07 04:44 PM
PivotTable Marek G Excel Discussion (Misc queries) 1 May 7th 05 12:50 AM
PivotTable - PivotTable Field name is not valid - error! miker1999[_17_] Excel Programming 1 June 10th 04 10:30 AM
Creating a PivotTable Report from an Another PivotTable Report bcpaulus Excel Programming 1 January 8th 04 07:56 PM


All times are GMT +1. The time now is 03:37 AM.

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"