How to calculate a "polynomial" set of data?

  • Thread starter DougW via AccessMonster.com
  • Start date
D

DougW via AccessMonster.com

I am trying to create a report on sets of parts.
Say I have 5 different parts, called A B C D E.
I have specifications that state how many of each part are needed to compose
a set.
Not all parts are needed in all sets.

I have a query that lists the parts delivered for a certain specification.
The query row includes columns called P1 P2 P3 P4 P5 and S1 S2 S3 S4 S5.
The P fields are the numbers of parts delivered, the S fields are the
"formula" for that spec,
or number of each part needed to compose one set.

How can I create a formula in my report to calculate how many sets of parts I
have for
a given row in my query? (I have to do it in the report since my P values
are summed
over time, and I have learned that running sums are not an option in queries.)


TIA,
Doug
 
E

Evi

Is this a crosstab query which you are referring to, Doug? If not, I have a
strong suspicion that you may have a database design problem. Give an
example of the data in say P1 and S1.

I'm trying to peer through the maze of jargon but what I'd expect to see in
your table design is

TblParts
PartID (primary Key, perhaps an Autonumber)
Part

TblSet (or the thing that motivates you to add parts together, perhaps a
customer's order
SetID (PK)
Eg SetDate

TblSetPart
SPID (PK)
PartID (Foreign Key field linked from TblParts
SpecID (FK linked from TblSet
PartNums (number of that part needed for that 'spec')


Evi
 
D

DougW via AccessMonster.com

Hello Evi,

This is another question on the DB which you gave me some advice on earlier.
The tables are fairly well "normalized" as best I can tell, arranged as
follows:

PrimaryParts (table)
PrimaryPartIndex (primary key)
PrimaryPartDesc (text describing this part type)
(Note: this short table describes 11 basic types of parts)

PrimaryPartArray (table)
PartArrayIndex (primary key)
PrimPartID (foreign key to PrimaryPartIndex in PrimaryParts table)
CompID (fk to OrderedItems table, not shown here)
DrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
BeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
DrumWidthID (fk to short DrumWidth table, listing of possible variants, not
shown)
QtyPerComp (quantity of this part per order)
(Note: this large table identifies a set of Part Types and their parameters
DrumSize, BeadSize and Drum Width that are associated with one ComponentID.
When one "component" is ordered on a purchase order it results in a
particular set of PrimaryParts. A "component" is a short-hand description of
a bill of materials - this table breaks that out into discrete "primary"
parts)

DrumSpecs (table)
DrumSpecIndex (PK)
SpecPartSetTypeID (fk to short PartSetType table, not shown)
SpecDrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
SpecBeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
SpecDrumWidthID (fk to short DrumWidth table, listing of possible variants,
not shown)
SpecDesc (text describing this spec)
(Note: this relatively short table describes the header information of my
list of specifications)

DrumSpecArray (table)
SpecArrayIndex (PK)
SpecID (fk to DrumSpecIndex in DrumSpec table)
SpecPrimPartID (fk to PrimaryPartIndex in PrimaryParts table)
SpecDrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
SpecBeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
SpecDrumWidthID (fk to short DrumWidth table, listing of possible variants,
not shown)
SpecPartQty (quantity of a given part needed to fulfill this specification)
(Note: this relatively large table describes the details of individual parts
and quantities that make up a particular specification. This is "the thing
that motivates me to put parts together" as you described)

My existing crosstab query generates the list by Parts described by their
PrimPartID and the 3 variants of DrumSize, BeadSize, DrumWidth, and the
quantity and delivery date of each of these parts. It is based on the
PrimaryPartArray table as joined to the DrumSpecArray table at these 3 fields.

My query describes the timetable that all the various unique parts will be
delivered.
It also identifies the SpecID (the particular specification) applicable to
each part ordered.


Here's the SQL of that query:

TRANSFORM Sum(PrimaryPartArray.QtyPerComp) AS SumOfQtyPerComp
SELECT [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered Items].
[Ship date (est)]
FROM [Purchase orders] INNER JOIN (DrumSpecArray INNER JOIN (PrimaryPartArray
INNER JOIN [Ordered Items] ON PrimaryPartArray.CompID = [Ordered Items].
Comp_index) ON (DrumSpecArray.SpecPrimPartID = PrimaryPartArray.PrimPartID)
AND (DrumSpecArray.SpecDrumSizeID = PrimaryPartArray.DrumSizeID) AND
(DrumSpecArray.SpecBeadSizeID = PrimaryPartArray.BeadSizeID) AND
(DrumSpecArray.SpecDrumWidthID = PrimaryPartArray.DrumWidthID)) ON [Purchase
orders].[PO number] = [Ordered Items].[PO Number]
GROUP BY [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered
Items].[Ship date (est)]
ORDER BY [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered
Items].[Ship date (est)]
PIVOT "PD" & PrimaryPartArray.PrimPartID In ("PD1","PD2","PD3","PD4","PD5",
"PD6","PD7","PD8","PD9","PD10","PD11");


So I know what parts are coming, when they will arrive, and what
specification pertains to each part.
I need a way to report on when I will accumulate enough parts to generate
each specification.
I think I need to generate a running sum of all parts by date, and on each of
those dates, calculate how many (if any) of the associated specification can
I assemble.

I hope that is not too much detail - thanks again!

-- Doug



Is this a crosstab query which you are referring to, Doug? If not, I have a
strong suspicion that you may have a database design problem. Give an
example of the data in say P1 and S1.

I'm trying to peer through the maze of jargon but what I'd expect to see in
your table design is

TblParts
PartID (primary Key, perhaps an Autonumber)
Part

TblSet (or the thing that motivates you to add parts together, perhaps a
customer's order
SetID (PK)
Eg SetDate

TblSetPart
SPID (PK)
PartID (Foreign Key field linked from TblParts
SpecID (FK linked from TblSet
PartNums (number of that part needed for that 'spec')

Evi
I am trying to create a report on sets of parts.
Say I have 5 different parts, called A B C D E.
[quoted text clipped - 20 lines]
 
E

Evi

Hi Doug.
The usual format for a Running Sum would be

RunSum: NZ(DSum("[Amount]","QryTest","[PrimPartID]=" & [PrimPartID] & " AND
[YourDate]<" & Format([YourDate],"0")),0)+[Amount]

(Replace Amount with field that counts the number of parts, replace YourDate
with the datefield, replace QryTest with the real name of your query)

You can add more AND's as you require.

If you need to count, rather than sum something, use DCount - the Syntax is
the same.

The syntax there assumes that PrimPartID is a number field - it is different
if it is a text field

I don't know how this would fit into your crosstab however. Would you be
able to put it into an ordinary query?

Evi

DougW via AccessMonster.com said:
Hello Evi,

This is another question on the DB which you gave me some advice on earlier.
The tables are fairly well "normalized" as best I can tell, arranged as
follows:

PrimaryParts (table)
PrimaryPartIndex (primary key)
PrimaryPartDesc (text describing this part type)
(Note: this short table describes 11 basic types of parts)

PrimaryPartArray (table)
PartArrayIndex (primary key)
PrimPartID (foreign key to PrimaryPartIndex in PrimaryParts table)
CompID (fk to OrderedItems table, not shown here)
DrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
BeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
DrumWidthID (fk to short DrumWidth table, listing of possible variants, not
shown)
QtyPerComp (quantity of this part per order)
(Note: this large table identifies a set of Part Types and their parameters
DrumSize, BeadSize and Drum Width that are associated with one ComponentID.
When one "component" is ordered on a purchase order it results in a
particular set of PrimaryParts. A "component" is a short-hand description of
a bill of materials - this table breaks that out into discrete "primary"
parts)

DrumSpecs (table)
DrumSpecIndex (PK)
SpecPartSetTypeID (fk to short PartSetType table, not shown)
SpecDrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
SpecBeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
SpecDrumWidthID (fk to short DrumWidth table, listing of possible variants,
not shown)
SpecDesc (text describing this spec)
(Note: this relatively short table describes the header information of my
list of specifications)

DrumSpecArray (table)
SpecArrayIndex (PK)
SpecID (fk to DrumSpecIndex in DrumSpec table)
SpecPrimPartID (fk to PrimaryPartIndex in PrimaryParts table)
SpecDrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
SpecBeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
SpecDrumWidthID (fk to short DrumWidth table, listing of possible variants,
not shown)
SpecPartQty (quantity of a given part needed to fulfill this specification)
(Note: this relatively large table describes the details of individual parts
and quantities that make up a particular specification. This is "the thing
that motivates me to put parts together" as you described)

My existing crosstab query generates the list by Parts described by their
PrimPartID and the 3 variants of DrumSize, BeadSize, DrumWidth, and the
quantity and delivery date of each of these parts. It is based on the
PrimaryPartArray table as joined to the DrumSpecArray table at these 3 fields.

My query describes the timetable that all the various unique parts will be
delivered.
It also identifies the SpecID (the particular specification) applicable to
each part ordered.


Here's the SQL of that query:

TRANSFORM Sum(PrimaryPartArray.QtyPerComp) AS SumOfQtyPerComp
SELECT [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered Items].
[Ship date (est)]
FROM [Purchase orders] INNER JOIN (DrumSpecArray INNER JOIN (PrimaryPartArray
INNER JOIN [Ordered Items] ON PrimaryPartArray.CompID = [Ordered Items].
Comp_index) ON (DrumSpecArray.SpecPrimPartID = PrimaryPartArray.PrimPartID)
AND (DrumSpecArray.SpecDrumSizeID = PrimaryPartArray.DrumSizeID) AND
(DrumSpecArray.SpecBeadSizeID = PrimaryPartArray.BeadSizeID) AND
(DrumSpecArray.SpecDrumWidthID = PrimaryPartArray.DrumWidthID)) ON [Purchase
orders].[PO number] = [Ordered Items].[PO Number]
GROUP BY [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered
Items].[Ship date (est)]
ORDER BY [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered
Items].[Ship date (est)]
PIVOT "PD" & PrimaryPartArray.PrimPartID In ("PD1","PD2","PD3","PD4","PD5",
"PD6","PD7","PD8","PD9","PD10","PD11");


So I know what parts are coming, when they will arrive, and what
specification pertains to each part.
I need a way to report on when I will accumulate enough parts to generate
each specification.
I think I need to generate a running sum of all parts by date, and on each of
those dates, calculate how many (if any) of the associated specification can
I assemble.

I hope that is not too much detail - thanks again!

-- Doug



Is this a crosstab query which you are referring to, Doug? If not, I have a
strong suspicion that you may have a database design problem. Give an
example of the data in say P1 and S1.

I'm trying to peer through the maze of jargon but what I'd expect to see in
your table design is

TblParts
PartID (primary Key, perhaps an Autonumber)
Part

TblSet (or the thing that motivates you to add parts together, perhaps a
customer's order
SetID (PK)
Eg SetDate

TblSetPart
SPID (PK)
PartID (Foreign Key field linked from TblParts
SpecID (FK linked from TblSet
PartNums (number of that part needed for that 'spec')

Evi
I am trying to create a report on sets of parts.
Say I have 5 different parts, called A B C D E.
[quoted text clipped - 20 lines]
 
E

Evi

Sorry Doug. I'm stumped on this. I can only think of using a subquery with
the crosstab as a basis for this query but I'm new to subqueries and would
probably need to re-create your database to experiment with it. Have a look
here and see if you can apply it, otherwise, if necessary, repost - with a
less daunting subject line
http://allenbrowne.com/subquery-01.html

Evi

DougW via AccessMonster.com said:
Hello Evi,

This is another question on the DB which you gave me some advice on earlier.
The tables are fairly well "normalized" as best I can tell, arranged as
follows:

PrimaryParts (table)
PrimaryPartIndex (primary key)
PrimaryPartDesc (text describing this part type)
(Note: this short table describes 11 basic types of parts)

PrimaryPartArray (table)
PartArrayIndex (primary key)
PrimPartID (foreign key to PrimaryPartIndex in PrimaryParts table)
CompID (fk to OrderedItems table, not shown here)
DrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
BeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
DrumWidthID (fk to short DrumWidth table, listing of possible variants, not
shown)
QtyPerComp (quantity of this part per order)
(Note: this large table identifies a set of Part Types and their parameters
DrumSize, BeadSize and Drum Width that are associated with one ComponentID.
When one "component" is ordered on a purchase order it results in a
particular set of PrimaryParts. A "component" is a short-hand description of
a bill of materials - this table breaks that out into discrete "primary"
parts)

DrumSpecs (table)
DrumSpecIndex (PK)
SpecPartSetTypeID (fk to short PartSetType table, not shown)
SpecDrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
SpecBeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
SpecDrumWidthID (fk to short DrumWidth table, listing of possible variants,
not shown)
SpecDesc (text describing this spec)
(Note: this relatively short table describes the header information of my
list of specifications)

DrumSpecArray (table)
SpecArrayIndex (PK)
SpecID (fk to DrumSpecIndex in DrumSpec table)
SpecPrimPartID (fk to PrimaryPartIndex in PrimaryParts table)
SpecDrumSizeID (fk to short DrumSize table, listing of possible variants, not
shown)
SpecBeadSizeID (fk to short BeadSize table, listing of possible variants, not
shown)
SpecDrumWidthID (fk to short DrumWidth table, listing of possible variants,
not shown)
SpecPartQty (quantity of a given part needed to fulfill this specification)
(Note: this relatively large table describes the details of individual parts
and quantities that make up a particular specification. This is "the thing
that motivates me to put parts together" as you described)

My existing crosstab query generates the list by Parts described by their
PrimPartID and the 3 variants of DrumSize, BeadSize, DrumWidth, and the
quantity and delivery date of each of these parts. It is based on the
PrimaryPartArray table as joined to the DrumSpecArray table at these 3 fields.

My query describes the timetable that all the various unique parts will be
delivered.
It also identifies the SpecID (the particular specification) applicable to
each part ordered.


Here's the SQL of that query:

TRANSFORM Sum(PrimaryPartArray.QtyPerComp) AS SumOfQtyPerComp
SELECT [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered Items].
[Ship date (est)]
FROM [Purchase orders] INNER JOIN (DrumSpecArray INNER JOIN (PrimaryPartArray
INNER JOIN [Ordered Items] ON PrimaryPartArray.CompID = [Ordered Items].
Comp_index) ON (DrumSpecArray.SpecPrimPartID = PrimaryPartArray.PrimPartID)
AND (DrumSpecArray.SpecDrumSizeID = PrimaryPartArray.DrumSizeID) AND
(DrumSpecArray.SpecBeadSizeID = PrimaryPartArray.BeadSizeID) AND
(DrumSpecArray.SpecDrumWidthID = PrimaryPartArray.DrumWidthID)) ON [Purchase
orders].[PO number] = [Ordered Items].[PO Number]
GROUP BY [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered
Items].[Ship date (est)]
ORDER BY [Purchase orders].DeliverLocnID, DrumSpecArray.SpecID, [Ordered
Items].[Ship date (est)]
PIVOT "PD" & PrimaryPartArray.PrimPartID In ("PD1","PD2","PD3","PD4","PD5",
"PD6","PD7","PD8","PD9","PD10","PD11");


So I know what parts are coming, when they will arrive, and what
specification pertains to each part.
I need a way to report on when I will accumulate enough parts to generate
each specification.
I think I need to generate a running sum of all parts by date, and on each of
those dates, calculate how many (if any) of the associated specification can
I assemble.

I hope that is not too much detail - thanks again!

-- Doug



Is this a crosstab query which you are referring to, Doug? If not, I have a
strong suspicion that you may have a database design problem. Give an
example of the data in say P1 and S1.

I'm trying to peer through the maze of jargon but what I'd expect to see in
your table design is

TblParts
PartID (primary Key, perhaps an Autonumber)
Part

TblSet (or the thing that motivates you to add parts together, perhaps a
customer's order
SetID (PK)
Eg SetDate

TblSetPart
SPID (PK)
PartID (Foreign Key field linked from TblParts
SpecID (FK linked from TblSet
PartNums (number of that part needed for that 'spec')

Evi
I am trying to create a report on sets of parts.
Say I have 5 different parts, called A B C D E.
[quoted text clipped - 20 lines]
 
D

DougW via AccessMonster.com

Hi Evi,

Thanks for the replies on this. I'm travelling and am away from my DB for
a week (probably a good thing...) but will try your suggestions when I get
back. I did look at the link to Allen Browne's explanation of subqueries,
and that seems very promising. A "filter" subquery may be what I need.

I will repost if and when I need more direction (very likely!)

thanks again,
Doug

Sorry Doug. I'm stumped on this. I can only think of using a subquery with
the crosstab as a basis for this query but I'm new to subqueries and would
probably need to re-create your database to experiment with it. Have a look
here and see if you can apply it, otherwise, if necessary, repost - with a
less daunting subject line
http://allenbrowne.com/subquery-01.html

Evi
Hello Evi,
[quoted text clipped - 127 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top