ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Pivot Table, Consolidating Columns (https://www.excelbanter.com/excel-programming/300167-pivot-table-consolidating-columns.html)

Melanie[_7_]

Pivot Table, Consolidating Columns
 
Hi,

I have some Pivot tables which get their data from an external
database, the table brings back 4 columns 2 fat results and 2 Solid
results

No.Fat-Average Fat-Average-Retest T.S.-Average T.S.-Average-Retest
1 5.125 22.665
2 5.02 22.555
3 5.05 23.37
4 5.175 22.7

What I want to do is only have one column for each result (one for
fat, one for solids) I can do this by creating a seperate column and
having an If statement with the final result in it, but I wondered if
there was a better way of consolidating the two columns into one?
Especially as for some of the tables there can be up to 8 columns with
only one having a result in it. Is there a way of doing this in the
SQL statement or am I stuck with huge if statements that change as my
columns change?
Any help would be much appreciated

Melanie

Jamie Collins

Pivot Table, Consolidating Columns
 
(Melanie) wrote ...

I have some Pivot tables which get their data from an external
database, the table brings back 4 columns 2 fat results and 2 Solid
results

No.Fat-Average Fat-Average-Retest T.S.-Average T.S.-Average-Retest
1 5.125 22.665
2 5.02 22.555
3 5.05 23.37
4 5.175 22.7

What I want to do is only have one column for each result (one for
fat, one for solids)


You may be able to achieve the desired result with the UNION keyword e.g.

SELECT
[Fat-Average] AS Fat,
[T.S.-Average] AS Solid
FROM Table1
UNION
SELECT
[Fat-Average-Retest] AS Fat,
[T.S.-Average-Retest] AS Solid
FROM Table2
;

Jamie.

--


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

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com