Fairly Complex Transform Pivot Query

kwilliam10

Board Regular
Joined
Sep 6, 2007
Messages
145
Hi all,

This might be a bit too much...but I'll give it a try with you guys. I have an excel spreadsheet, where I have 3 different tabs (each with a query) which I want to join into one Transform-Pivot result. The reason I have the Transform-Pivot...is because I am aging Accounts Receivable..and using the Transform-Pivot to reflect the Aged Balances, by project. The other queries are pulling in additional information for each project.

The result would be similar to this:

Aged AR Query.xls
ABCDEFGHIJKLMNOP
7WBS1CurrencyClientNameEntityCenterSectorClientTypeFederalIndMultAmtRevTypeRetainerBalanceCurrent31-6061-9091-120
800-02070.28USDNewYorkState000230SN-65000PROFIT112,315.00
900-03077.13USDJohnsHopkinsUniversity000130PN0B17,193.3117,193.31
1000-04062.33USDMPO002230GY0COMPLETE99,124.75
1100-04062.36USDMarylandProcurementOffice002230SY0COMPLETE35,134.79
1200-04062.46USDMarylandProcurementOffice000230SN0B600.00600.00
1300-04062.51USDMarylandProcurementOffice000230SN0PCT_EAC16,717.2916,717.29
1400-04068.02USDAlGhurairCentreLLC002150IN0PCT_EAC140,988.808,000.0371,190.219,098.56
1500-04068.03USDAlGhurairCentreLLC002150IN0LS_UNDER10,000.00
TotalDetail


Here is my code for the Transform-Pivot query:

Transform sum(qryARBals.Balance)
SELECT qryARBals.Entity, qryARBals.WBS1, qryARBals.BillingCurrencyCode, qryProjInfo.ClientName, qryProjInfo.ClientType, qryProjInfo.FederalInd, qryProjInfo.MultAmt, qryProjInfo.RevType, qryRetainer.Retainer, sum(qryARBals.Balance) as [Balance], qryProjInfo.Center, qryProjInfo.Sector
FROM (`V:\Finance\AR\2009\Aged AR Query`.qryARBals qryARBals inner join
`V:\Finance\AR\2009\Aged AR Query`.qryProjInfo qryProjInfo on qryARBals.WBS1 = qryProjInfo.WBS1)
LEFT OUTER JOIN `V:\Finance\AR\2009\Aged AR Query`.qryRetainer qryRetainer ON qryARBals.WBS1 = qryRetainer.WBS1
Group by qryARBals.Entity, qryARBals.WBS1, qryARBals.BillingCurrencyCode, qryProjInfo.ClientName, qryProjInfo.ClientType, qryProjInfo.FederalInd, qryProjInfo.MultAmt, qryProjInfo.RevType, qryRetainer.Retainer, qryProjInfo.Center, qryProjInfo.Sector
Pivot qryARBals.Age



My dilema is that right now the code (above) is based on a one-to-one relationship between qryARBals and qryProjInfo. I really need to change this to be a Left Outer Join of qryARBals to qry ProjInfo. This is because the last query I am joining to the Transform-Pivot (qryRetainer) has activity for projects that are not on qryARBals query. The qryProjInfo query includes ALL projects. I need to change this up so that the qryProjInfo is the left most data ...and two Outer Joins for the other queries. HOWEVER...this would mean that on the Transform-Pivot...I would have some nulls. I believe that NZ() does not work in excel sql (at least I was not able to get it to work.) Anyone have any ideas how I can get the two lines of this code to work? Even if I could get the nz() to work...I would also have to do some sort of case statement for the "Pivot qryARBals.Age" line...because there would be no age for that data either.

Hope there is someone that can help me.

Thanks,

Keith W.
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand

Forum statistics

Threads
1,225,767
Messages
6,186,907
Members
453,386
Latest member
testmaster

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