+ Reply to Thread
Results 1 to 2 of 2

Thread: Union in Nested IF Statements

  1. #1
    Registered User
    Join Date
    03-18-2011
    Location
    NY, NY
    MS-Off Ver
    Excel 2003
    Posts
    2

    Exclamation Union in Nested IF Statements

    All,

    My question related around nested IF statements and a Union. I am trying to figure out how the last component of the formula should force the query to do a union on data (like a lookup) if it runs through all the previous tests.

    In design mode it looks like this:

    Prod Detail (Pre): IIf([*2011 Corp (P1 & PGS)]![L9 Cost Cent Desc]="TOTAL CORE FI DCM US CONDUITS" And [*2011 Corp (P1 & PGS)]![L1 Orig Prod Desc]="Origination Income","Conduits",IIf([*2011 Corp (P1 & PGS)]!Product1="Portfolio" And [*2011 Corp (P1 & PGS)]![Source System Code]="TLP","TLP",IIf([*2011 Corp (P1 & PGS)]![L8 Cost Cent Desc]="Total Core Mortgage Trading" And [*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="DCM Origination","DCM",IIf([*2011 Corp (P1 & PGS)]!Product1="Markets" And [*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="Eq Cash","Markets Other",IIf([*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="DCM Origination Cross Sell","Cross Sell",IIf([*2011 Corp (P1 & PGS)]![L2 Orig Prod Desc]="Deduplication Cross Sell","Solution Sales",IIf([*2011 Corp (P1 & PGS)]!Product1="Markets" And [*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="Syndicate","Markets Other", Insert Union Here )))))))

    OR in SQL Mode:

    SELECT [*2011 Corp (P1 & PGS)].*, IIf([*2011 Corp (P1 & PGS)]![L9 Cost Cent Desc]="TOTAL CORE FI DCM US CONDUITS" And [*2011 Corp (P1 & PGS)]![L1 Orig Prod Desc]="Origination Income","Conduits",IIf([*2011 Corp (P1 & PGS)]!Product1="Portfolio" And [*2011 Corp (P1 & PGS)]![Source System Code]="TLP","TLP",IIf([*2011 Corp (P1 & PGS)]![L8 Cost Cent Desc]="Total Core Mortgage Trading" And [*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="DCM Origination","DCM",IIf([*2011 Corp (P1 & PGS)]!Product1="Markets" And [*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="Eq Cash","Markets Other",IIf([*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="DCM Origination Cross Sell","Cross Sell",IIf([*2011 Corp (P1 & PGS)]![L2 Orig Prod Desc]="Deduplication Cross Sell","Solution Sales",IIf([*2011 Corp (P1 & PGS)]!Product1="Markets" And [*2011 Corp (P1 & PGS)]![L3 Orig Prod Desc]="Syndicate","Markets Other"))))))) AS [Prod Detail (Pre)]
    FROM [*2011 Corp (P1 & PGS)];

    My skill in writing SQL is moderate, so I needed the advice on how to best create this. As I said, ultimately, this Union should happen after running through all the other tests and is the last component (similar to a vlookup).


    Appreciate all input.

  2. #2
    Valued Forum Contributor alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Lake County, Illinois
    MS-Off Ver
    MS Office 2010, 2007 and 2002
    Posts
    1,161

    Re: Union in Nested IF Statements


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0