Microsoft Office Forums


Reply
Thread Tools Display Modes

Sorting and calculating within different fields

 
 
Michele E
Guest
Posts: n/a
 
      02-23-2010, 01:58 PM
I have a database in which production data is entered. There is a field for
the [Rolls Produced] which is the total number of rolls of product we made
during a given shift. There is also an [Off Quality] field which gives the
total number of "bad" (not good quality) rolls that were made. I have 4 other
field which list the top number 1, 2, 3 and 4 reasons for the off quality
rolls. These fields are drop down list that the data entry person can choose
from. I aslo have 4 more fields to input the [Amount] of number of rolls
associated with each [Reason].

I need to report a summary that will give me the top reasons (and amounts)
for a given time period. I have created a query and a form (to input the
start and end date), but I do not know how to tell the report (or query) how
to sort the data by [Reason] and then add up the [Amounts] for each reason,
when there are 4 different [Reason] fields and 4 dfferent [Amount] fields.

My data looks like this:
Total Rolls Off Quality Reason 1 Amount 1 Reason 2 Amount 2
Reason 3.....
100 25 bad egdes 15 wrong size 10
98 12 wrong size 10 dirty
2

In many cases, the top reason (#1) will not always be the same, so I need to
add different field names together, based on the [Reason] for the off quality
rolls.

Can you help me?
Thanks.
--
Michele E
 
Reply With Quote
 
 
 
 
Jerry Whittle
Guest
Posts: n/a
 
      02-23-2010, 02:39 PM
The root problem is the table design. When you find yourself going across
with similar fields, such as your 4 other fields, you are treating Access
like a spreadsheet.

Simple question: What happens when someone demands that you track 5 things
instead of 4? You have to modify your table the queries, forms, and reports
based on that table. Then they want 6 instead of 5.....

What you need is an "Off Quality" table linked to the original. It it you
would have fields like

OQ_ID (primary key)
Rolls_ID (foriegn key to the original table)
OQ_Amount (number)
OQ_Reason (text)

You might even what a lookup table or list for the OQ_Reason field that
lists the common reasons in a combo or list box.

With the above you can has as few or as many OQ's per Roll as needed. You
also won't need an [Off Quality] field in the original table as you can just
count them up in the second table.

Next you can link these tables in a query to get the data that you need. To
get the particular format like below, you'll then need a crosstab query.

Easy to design and set up? Nope!

Give you the information that you need once set up properly plus be
expandable? Yep!
--
Jerry Whittle, Microsoft Access MVP
Light. Strong. Cheap. Pick two. Keith Bontrager - Bicycle Builder.


"Michele E" wrote:

> I have a database in which production data is entered. There is a field for
> the [Rolls Produced] which is the total number of rolls of product we made
> during a given shift. There is also an [Off Quality] field which gives the
> total number of "bad" (not good quality) rolls that were made. I have 4 other
> field which list the top number 1, 2, 3 and 4 reasons for the off quality
> rolls. These fields are drop down list that the data entry person can choose
> from. I aslo have 4 more fields to input the [Amount] of number of rolls
> associated with each [Reason].
>
> I need to report a summary that will give me the top reasons (and amounts)
> for a given time period. I have created a query and a form (to input the
> start and end date), but I do not know how to tell the report (or query) how
> to sort the data by [Reason] and then add up the [Amounts] for each reason,
> when there are 4 different [Reason] fields and 4 dfferent [Amount] fields.
>
> My data looks like this:
> Total Rolls Off Quality Reason 1 Amount 1 Reason 2 Amount 2
> Reason 3.....
> 100 25 bad egdes 15 wrong size 10
> 98 12 wrong size 10 dirty
> 2
>
> In many cases, the top reason (#1) will not always be the same, so I need to
> add different field names together, based on the [Reason] for the off quality
> rolls.
>
> Can you help me?
> Thanks.
> --
> Michele E

 
Reply With Quote
 
Daryl S
Guest
Posts: n/a
 
      02-23-2010, 02:48 PM
Michele -

This problem could have been prevented with a better database design (e.g.
each reason and count having it's own line in a separate table linked to the
shift. Anyway, given what you have, you can do this. I assume you have a
table of Reasons that is used for the drop-list. You will need to change the
names of the tables and fields to match your data. This basically makes a
cartesian query, then sums the amounts from all four fields for each reason:

SELECT Reasons.Reason, sum(Iif([ShiftRolls].[Reason 1] =
Reasons.Reason,[Amount 1],0) + sum(Iif([ShiftRolls].[Reason 2] =
Reasons.Reason,[Amount 2],0) + Iif([ShiftRolls].[Reason 3] =
Reasons.Reason,[Amount 3],0) + sum(Iif([ShiftRolls].[Reason 4] =
Reasons.Reason,[Amount 42],0))
FROM Reasons, ShiftRolls
WHERE ShiftRolls.ShiftDate Between [Enter Start Date:] AND [Enter End Date:]
GROUP BY Reasons.Reason;

--
Daryl S


"Michele E" wrote:

> I have a database in which production data is entered. There is a field for
> the [Rolls Produced] which is the total number of rolls of product we made
> during a given shift. There is also an [Off Quality] field which gives the
> total number of "bad" (not good quality) rolls that were made. I have 4 other
> field which list the top number 1, 2, 3 and 4 reasons for the off quality
> rolls. These fields are drop down list that the data entry person can choose
> from. I aslo have 4 more fields to input the [Amount] of number of rolls
> associated with each [Reason].
>
> I need to report a summary that will give me the top reasons (and amounts)
> for a given time period. I have created a query and a form (to input the
> start and end date), but I do not know how to tell the report (or query) how
> to sort the data by [Reason] and then add up the [Amounts] for each reason,
> when there are 4 different [Reason] fields and 4 dfferent [Amount] fields.
>
> My data looks like this:
> Total Rolls Off Quality Reason 1 Amount 1 Reason 2 Amount 2
> Reason 3.....
> 100 25 bad egdes 15 wrong size 10
> 98 12 wrong size 10 dirty
> 2
>
> In many cases, the top reason (#1) will not always be the same, so I need to
> add different field names together, based on the [Reason] for the off quality
> rolls.
>
> Can you help me?
> Thanks.
> --
> Michele E

 
Reply With Quote
 
Michele E
Guest
Posts: n/a
 
      02-24-2010, 04:41 PM
Hi Daryl.

Thank you. What does your [ShiftRolls] represent? The number of off quality
rolls?
I am new to Access. Would developing a crosstab query be too difficult - do
you think?
--
Michele E


"Daryl S" wrote:

> Michele -
>
> This problem could have been prevented with a better database design (e.g.
> each reason and count having it's own line in a separate table linked to the
> shift. Anyway, given what you have, you can do this. I assume you have a
> table of Reasons that is used for the drop-list. You will need to change the
> names of the tables and fields to match your data. This basically makes a
> cartesian query, then sums the amounts from all four fields for each reason:
>
> SELECT Reasons.Reason, sum(Iif([ShiftRolls].[Reason 1] =
> Reasons.Reason,[Amount 1],0) + sum(Iif([ShiftRolls].[Reason 2] =
> Reasons.Reason,[Amount 2],0) + Iif([ShiftRolls].[Reason 3] =
> Reasons.Reason,[Amount 3],0) + sum(Iif([ShiftRolls].[Reason 4] =
> Reasons.Reason,[Amount 42],0))
> FROM Reasons, ShiftRolls
> WHERE ShiftRolls.ShiftDate Between [Enter Start Date:] AND [Enter End Date:]
> GROUP BY Reasons.Reason;
>
> --
> Daryl S
>
>
> "Michele E" wrote:
>
> > I have a database in which production data is entered. There is a field for
> > the [Rolls Produced] which is the total number of rolls of product we made
> > during a given shift. There is also an [Off Quality] field which gives the
> > total number of "bad" (not good quality) rolls that were made. I have 4 other
> > field which list the top number 1, 2, 3 and 4 reasons for the off quality
> > rolls. These fields are drop down list that the data entry person can choose
> > from. I aslo have 4 more fields to input the [Amount] of number of rolls
> > associated with each [Reason].
> >
> > I need to report a summary that will give me the top reasons (and amounts)
> > for a given time period. I have created a query and a form (to input the
> > start and end date), but I do not know how to tell the report (or query) how
> > to sort the data by [Reason] and then add up the [Amounts] for each reason,
> > when there are 4 different [Reason] fields and 4 dfferent [Amount] fields.
> >
> > My data looks like this:
> > Total Rolls Off Quality Reason 1 Amount 1 Reason 2 Amount 2
> > Reason 3.....
> > 100 25 bad egdes 15 wrong size 10
> > 98 12 wrong size 10 dirty
> > 2
> >
> > In many cases, the top reason (#1) will not always be the same, so I need to
> > add different field names together, based on the [Reason] for the off quality
> > rolls.
> >
> > Can you help me?
> > Thanks.
> > --
> > Michele E

 
Reply With Quote
 
Daryl S
Guest
Posts: n/a
 
      02-24-2010, 07:22 PM
Michele -

The [ShiftRolls] should be the table where you have the number of off
quality rolls stored.

A crosstab query would be perfect if your table design was the way I
mentioned it in the previous post. They are easy to build if the table is
set up properly.

Try the query, and if you have any issues, post the SQL to what you are
working on, and we can try to help more.

--
Daryl S


"Michele E" wrote:

> Hi Daryl.
>
> Thank you. What does your [ShiftRolls] represent? The number of off quality
> rolls?
> I am new to Access. Would developing a crosstab query be too difficult - do
> you think?
> --
> Michele E
>
>
> "Daryl S" wrote:
>
> > Michele -
> >
> > This problem could have been prevented with a better database design (e.g.
> > each reason and count having it's own line in a separate table linked to the
> > shift. Anyway, given what you have, you can do this. I assume you have a
> > table of Reasons that is used for the drop-list. You will need to change the
> > names of the tables and fields to match your data. This basically makes a
> > cartesian query, then sums the amounts from all four fields for each reason:
> >
> > SELECT Reasons.Reason, sum(Iif([ShiftRolls].[Reason 1] =
> > Reasons.Reason,[Amount 1],0) + sum(Iif([ShiftRolls].[Reason 2] =
> > Reasons.Reason,[Amount 2],0) + Iif([ShiftRolls].[Reason 3] =
> > Reasons.Reason,[Amount 3],0) + sum(Iif([ShiftRolls].[Reason 4] =
> > Reasons.Reason,[Amount 42],0))
> > FROM Reasons, ShiftRolls
> > WHERE ShiftRolls.ShiftDate Between [Enter Start Date:] AND [Enter End Date:]
> > GROUP BY Reasons.Reason;
> >
> > --
> > Daryl S
> >
> >
> > "Michele E" wrote:
> >
> > > I have a database in which production data is entered. There is a field for
> > > the [Rolls Produced] which is the total number of rolls of product we made
> > > during a given shift. There is also an [Off Quality] field which gives the
> > > total number of "bad" (not good quality) rolls that were made. I have 4 other
> > > field which list the top number 1, 2, 3 and 4 reasons for the off quality
> > > rolls. These fields are drop down list that the data entry person can choose
> > > from. I aslo have 4 more fields to input the [Amount] of number of rolls
> > > associated with each [Reason].
> > >
> > > I need to report a summary that will give me the top reasons (and amounts)
> > > for a given time period. I have created a query and a form (to input the
> > > start and end date), but I do not know how to tell the report (or query) how
> > > to sort the data by [Reason] and then add up the [Amounts] for each reason,
> > > when there are 4 different [Reason] fields and 4 dfferent [Amount] fields.
> > >
> > > My data looks like this:
> > > Total Rolls Off Quality Reason 1 Amount 1 Reason 2 Amount 2
> > > Reason 3.....
> > > 100 25 bad egdes 15 wrong size 10
> > > 98 12 wrong size 10 dirty
> > > 2
> > >
> > > In many cases, the top reason (#1) will not always be the same, so I need to
> > > add different field names together, based on the [Reason] for the off quality
> > > rolls.
> > >
> > > Can you help me?
> > > Thanks.
> > > --
> > > Michele E

 
Reply With Quote
 
James A. Fortune
Guest
Posts: n/a
 
      02-25-2010, 01:41 PM
On Feb 24, 5:09 pm, "KenSheridan via AccessMonster.com" <u51882@uwe>
wrote:

> Nevertheless, the data can be
> tortured into confessing by means of a UNION ALL operation, e.g.


Duke: Put them in the iron maiden.

Bill & Ted: Iron Maiden? Excellent!!!

-- Bill and Ted's Excellent Adventure

James A. Fortune
(E-Mail Removed)

[L. A. Waddell] is a wild ride, and a wild read.
 
Reply With Quote
 
Michele E
Guest
Posts: n/a
 
      03-08-2010, 03:04 PM
Thank you, everyone. I ended up making another table and linking them. I
believe this should work well.

--
Michele E


"James A. Fortune" wrote:

> On Feb 24, 5:09 pm, "KenSheridan via AccessMonster.com" <u51882@uwe>
> wrote:
>
> > Nevertheless, the data can be
> > tortured into confessing by means of a UNION ALL operation, e.g.

>
> Duke: Put them in the iron maiden.
>
> Bill & Ted: Iron Maiden? Excellent!!!
>
> -- Bill and Ted's Excellent Adventure
>
> James A. Fortune
> (E-Mail Removed)
>
> [L. A. Waddell] is a wild ride, and a wild read.
> .
>

 
Reply With Quote
 
De Jager
Guest
Posts: n/a
 
      03-13-2010, 04:40 PM

"Michele E" <(E-Mail Removed)> wrote in message
news1819501-513E-43B9-BC48-(E-Mail Removed)...
> Thank you, everyone. I ended up making another table and linking them. I
> believe this should work well.
>
> --
> Michele E
>
>
> "James A. Fortune" wrote:
>
>> On Feb 24, 5:09 pm, "KenSheridan via AccessMonster.com" <u51882@uwe>
>> wrote:
>>
>> > Nevertheless, the
>> > data can be
>> > tortured into confessing by means of a UNION ALL operation, e.g.

>>
>> Duke: Put them in the iron maiden.
>>
>> Bill & Ted: Iron Maiden? Excellent!!!
>>
>> -- Bill and Ted's Excellent Adventure
>>
>> James A. Fortune
>> (E-Mail Removed)
>>
>> [L. A. Waddell] is a wild ride, and a wild read.
>> .
>>


 
Reply With Quote
 
joelgeraldine
Guest
Posts: n/a
 
      03-17-2010, 12:49 PM
kjjkjkj

"Michele E" <(E-Mail Removed)> a écrit dans le message de
groupe de discussion : D1819501-513E-43B9-BC48-(E-Mail Removed)...
> Thank you, everyone. I ended up making another table and linking them. I
> believe this should work well.
>
> --
> Michele E
>
>
> "James A. Fortune" wrote:
>
>> On Feb 24, 5:09 pm, "KenSheridan via AccessMonster.com" <u51882@uwe>
>> wrote:
>>
>> > Nevertheless, the
>> > data can be
>> > tortured into confessing by means of a UNION ALL operation, e.g.

>>
>> Duke: Put them in the iron maiden.
>>
>> Bill & Ted: Iron Maiden? Excellent!!!
>>
>> -- Bill and Ted's Excellent Adventure
>>
>> James A. Fortune
>> (E-Mail Removed)
>>
>> [L. A. Waddell] is a wild ride, and a wild read.
>> .
>>

 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




All times are GMT. The time now is 08:22 PM.
Microsoft Office Forums is not affiliated with Microsoft Corporation.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92