Rabu, 18 Januari 2017

Re: [MS_AccessPros] Crosstab Multiple Fields

 

I think I should have made this a little more explicit. FieldName should not be a Row Heading. It is only used in the Column Headings.


Duane




From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of Duane Hookom duanehookom@hotmail.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Wednesday, January 18, 2017 4:26 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: Re: [MS_AccessPros] Crosstab Multiple Fields
 


Bob,


Try remove FieldName from the Group By.


Regards,

Duane




From: MS_Access_Professionals@yahoogroups.com <MS_Access_Professionals@yahoogroups.com> on behalf of 'Bob Phillips' bob.phillips@dsl.pipex.com [MS_Access_Professionals] <MS_Access_Professionals@yahoogroups.com>
Sent: Wednesday, January 18, 2017 4:16 AM
To: MS_Access_Professionals@yahoogroups.com
Subject: [MS_AccessPros] Crosstab Multiple Fields
 


I am trying to create a crosstab report showing multiple values. I am using a technique that I found as described by Allen Browne, create a single column table with the field names as rows, add it withoiut joining in the query, and an IIF statement to test the value in this table in the TRANSFORM which determine what is aggregated.

 

TRANSFORM IIf(IsNull(IIf([Fieldname]="Upsells",

                     SUM(trk.LengthOfStay),

                     COUNT(trk.StaffID)

                    )

              ),

              0,

              IIf([Fieldname]="Upsells",SUM(trk.LengthOfStay),Count(trk.StaffID))

             ) AS TotalUpsells

SELECT prop.PropertyName

FROM tblColumns,

Region AS reg

    INNER JOIN ((Country AS cty

    INNER JOIN (Brand AS brnd

    INNER JOIN (Area INNER JOIN (Division AS div

    INNER JOIN (Contract AS con

    INNER JOIN Property AS prop

        ON con.ContractID = prop.ContractID)

        ON div.DivisionID = prop.DivisionID)

        ON area.AreaID = prop.AreaID)

        ON brnd.BrandID = prop.BrandID)

        ON cty.CountryID = prop.CountryID)

    INNER JOIN Tracking AS trk

        ON prop.PropertyID = trk.PropertyID)

        ON reg.RegionID = prop.RegionID

WHERE trk.TrackingYear = 2016

GROUP BY reg.RegionID, prop.PropertyName, FieldName PIVOT Fieldname & reg.RegionID;

 

It works to an extent, but I get two lines per property, the first shows the nights, the second shows the upsells. Allen’s example creates single rows.

 

Can anyone give me a steer as to what to change to get them on the same line?

 

TIA

 





__._,_.___

Posted by: Duane Hookom <duanehookom@hotmail.com>
Reply via web post Reply to sender Reply to group Start a New Topic Messages in this topic (3)

Have you tried the highest rated email app?
With 4.5 stars in iTunes, the Yahoo Mail app is the highest rated email app on the market. What are you waiting for? Now you can access all your inboxes (Gmail, Outlook, AOL and more) in one place. Never delete an email again with 1000GB of free cloud storage.


.

__,_._,___

Tidak ada komentar:

Posting Komentar