Solved

Access transpose issue - task by due date

Posted on 2015-01-14
8
179 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

 

Author Comment

by:atljarman
ID: 40549925
I will give this a try tonight and report back.
0
 

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

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.

Question has a verified solution.

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

Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
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…

733 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