Solved

Access transpose issue - task by due date

Posted on 2015-01-14
8
176 Views
Last Modified: 2015-03-07
Hi,

I've got a fairly simple transpose issue that I can seem to figure out.  I found my old post completed by Capricorn1 and that did not solve my problem and I can't figure out what is wrong.

So I have data like this with say 4 Departments.
Due,Task,Dept,Completed
1/1/2015,Eat Lunch,A
1/1/2015,Eat Lunch,B,1/1/2015
1/1/2015,Eat Lunch,C
1/2/2015,Go Home,A
1/2/2015,Go Home,B,1/2/2015
1/2/2015,Go Home,C,1/2/2015
1/2/2015,Go Home,D,1/2/2015

What I need it to look like is:
Due              Task             A                B                   C                  D
1/1/2015  Eat Lunch                   1/1/2015                             N/A (no task for D)
1/2/2015  Go Home                    1/2/2015        1/2/2015    1/2/2015

From the transposed data, you can quickly see that Dept A has not completed either task, B is Ok, C has one task yet, and D only had one task as they didn't need to eat lunch for some reason (maybe the were fasting).

I spent probably more time that I should have trying figure this out.  Capricorn1 if you see this....  Others you may be able to help.
0
Comment
Question by:atljarman
  • 4
  • 4
8 Comments
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 500 total points
ID: 40549852
Not s0 elegant but try this:

Create a group by query like this, and name it "1":
SELECT YourTable.Due, YourTable.Task
FROM YourTable
GROUP BY YourTable.Due, YourTable.Task;

Create a Crosstab query like this and name it "2":
TRANSFORM First(YourTable.[Completed]) AS FirstOfCompleted
SELECT YourTable.[Due], First(YourTable.[Completed]) AS [Total Of Completed]
FROM YourTable
GROUP BY YourTable.[Due]
PIVOT YourTable.[Dept];

Create a third query, (joining the first two), like this, and name it "3"
SELECT [1].Due, [1].Task, [2].A, [2].B, [2].C, [2].D
FROM 1 INNER JOIN 2 ON [1].Due = [2].Due;

Now "3" should give you the output you specified...

sample attached:


JeffCoachman
Database51.mdb
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40549860
Like so
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40549885
Actually, ...you may not even need query "1" or "2", ...
...just make a query like this:

TRANSFORM First(YourTable.Completed) AS FirstOfCompleted
SELECT YourTable.Due, YourTable.Task
FROM YourTable
GROUP BY YourTable.Due, YourTable.Task
PIVOT YourTable.Dept;
0
 

Author Comment

by:atljarman
ID: 40549925
I will give this a try tonight and report back.
0
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 

Author Comment

by:atljarman
ID: 40550454
Jeffery, your transform code works good.  Just not sure what to do as the one record that should show an N/A does not appear.  Is there a way to indicate that no record existed for that user.  It appears that the user has something that is required to be done.  So Eat Lunch for Dept D should show a value of N/A.  Is that possible?
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 40551422
This will be difficult as you structure does not define what a "missing" value should be,...
Further complicating this is that the Transform is a "summary", ...it cannot easily be made to show when a value might be missing form one of its components..

For example, if you have a sum of the 10 Sales you had in Spain.
You also have a sum of sales for USA, ...but USA only had 9 sales...
How is the summary to "know" that all sales sums require 10 values? (USA is missing a sale)

Now let's suppose that Germany had 11 sales...
Does this mean that Germany has "too many" sales (one extra or erroneous sale, ...or is it that both Spain and USA have "too Few"?

Finally, to me, ...a records with no completed date is "irrelevant" to the transform as well...
How can you have a record be considered in a summary when it is not finished yet, AFAIC, ...that record should not be considered, ...just as a "missing" record should not be considered...
So in the same way that these "incomplete" records are being created (and considered as part of he summary), ...then why cant the "D" create an incomplete record as well? (just as A, B, and C did?)
0
 

Author Comment

by:atljarman
ID: 40611529
I am still reviewing this response.  I actually have data now and diagnosing any issue
0
 

Author Closing Comment

by:atljarman
ID: 40651215
This was really helpful.  Sorry I am so late in responding.  I had to transfer live data to the application and test.  My work around for adding N/A was to concatenate responsibilities then to do a string comparison in the REPORT.  This was a HUGE pain because every time I opened the report it would run the script on every row to concat the responsibilities (not shown here).  The trick was to shut off that function while editing the other parts of the report.  I turned the concat function on and it worked like a charm.  

BTW... i'm not a fan of the way this report was written. I did create a filter so that the reports datasource could be changed.  I think that there would be much more valuable reports but had to meet the requirements on this one.  Thanks a million.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now