Solved

Access transpose issue - task by due date

Posted on 2015-01-14
8
172 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
Comment Utility
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
Comment Utility
Like so
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
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
Comment Utility
I will give this a try tonight and report back.
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:atljarman
Comment Utility
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
Comment Utility
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
Comment Utility
I am still reviewing this response.  I actually have data now and diagnosing any issue
0
 

Author Closing Comment

by:atljarman
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

762 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

9 Experts available now in Live!

Get 1:1 Help Now