Results 1 to 5 of 5
  1. #1
    zminek21 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2013
    Posts
    3

    Cross Queries

    Hi,

    I have a problem with cross-queries.

    I need to show in table in the line all records of base "placowki" and in the column all records of base "koordynator".

    So...when the value in table for exemplary line is null...i need to see there value 0....and not hide this line. It is possible?

    In addition, I would like to add summary-rows for column and line.

    In Annex I send an example.

    Thanks!



    Mariusz
    Attached Files Attached Files

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I think your options are:

    1. build another query that uses the crosstab as data source:
    SELECT *, Nz([Aleksandra Rudka],0) As RudkaCount FROM KwerendaKrzyz;

    2. build a report and do the Nz calc in a textbox

    3. do a fake crosstab http://www.datapigtechnologies.com/f.../crosstab.html
    The expressions would be like: Nz(Sum(IIf([Koordynator="Aleksandra Rudka",1,0)),0)



    To get sums, open query and click Totals from the ribbon. This opens a Totals row, pick the operation you want under each field.
    Or build a report and have calcs in textboxes in report footer.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    zminek21 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2013
    Posts
    3
    Thank you

    Ok, "disappearing columnt" is done....now rows. If we set the date criteria to >#2013-09-09# .... disappears eg rows "Krosno". Is it possible to show row "Krosno" with result 0 0 0 for each column? AAA2.zip

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Why are you summing the Koordynator field? This is the Koordynator ID.

    You have relationships joined on the wrong fields. I am surprised Access allowed you to join a number field to a text field in the Relationship builder. PK/FK fields must be same data type. Joins should be between IDkoordynator to Koordyntor and IDplacowka to Placowka.

    Join Type: Include ALL records from 'Wizyty' and only those from ...

    SELECT Placówki.Placówka, Sum(IIf([Wizyty].[Koordynator]=4,1,0)) AS Przemek, Sum(IIf([Wizyty].[Koordynator]=2,1,0)) AS Asia, Sum(IIf([Wizyty].[Koordynator]=3,1,0)) AS Basia
    FROM Wizyty RIGHT JOIN Placówki ON Wizyty.Placówka = Placówki.IDplacowka
    WHERE (((Wizyty.Data)>#9/9/2013#))
    GROUP BY Placówki.Placówka;

    Krosno still will not show because it does not have any records that meet the date criteria. To assure every Placowka is always listed requires at least one record that meets the criteria. This can be accomplished if there is a dataset that associates each Placowka with every possible date in Wizyty. This dataset can be created with a cartesian query:

    SELECT Placówki.IDplacowka, Wizyty.Data FROM Placówki, Wizyty;

    Without a JOIN clause, every record from each table will join to every record of the other table. This query can be used in other query to assure a record for every Placowka.

    SELECT Placówki.Placówka, Sum(IIf([Wizyty].[Koordynator]=4,1,0)) AS Przemek, Sum(IIf([Wizyty].[Koordynator]=2,1,0)) AS Asia, Sum(IIf([Wizyty].[Koordynator]=3,1,0)) AS Basia
    FROM (Wizyty RIGHT JOIN AllDates ON (Wizyty.Placówka = AllDates.IDplacowka) AND (Wizyty.Data = AllDates.Data)) LEFT JOIN Placówki ON AllDates.IDplacowka = Placówki.IDplacowka
    WHERE (((Wizyty.Data)>#9/9/2013#))
    GROUP BY Placówki.Placówka;

    Dates in Wizyty are saved as dd/mm/yyyy. This causes me issues when I try to sort/filter because I am in U.S. and follow mm/dd/yyyy structure which is the Access default. So my test of the above queries fails to return desired records. Review http://allenbrowne.com/ser-36.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    zminek21 is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2013
    Posts
    3
    It doesn't work...Krosno still is not showing....but I think that it is good way to solve this problem. I'll be working on it.
    Attached Files Attached Files

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Combining Results of Cross Tab Queries
    By kkyork in forum Queries
    Replies: 4
    Last Post: 06-06-2012, 09:10 AM
  2. Cross tab help
    By A S MANN in forum Queries
    Replies: 5
    Last Post: 10-28-2010, 07:46 AM
  3. Cross-tab query YTD
    By stremchem in forum Queries
    Replies: 9
    Last Post: 08-26-2010, 10:09 AM
  4. Cross Tab Query
    By RycherX in forum Queries
    Replies: 1
    Last Post: 04-26-2010, 12:19 PM
  5. Cross Tab Queries
    By Nixx1401 in forum Access
    Replies: 6
    Last Post: 02-16-2010, 11:55 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums