Duplicates
13 November, 2012
The scenario:
I am attempting to create a Customer sales report which will display the total quantity, amount and cost of sales per customer for a period of time.
The Quantity is on the �Item Ledger Entry� table and the sales and cost amounts on the Value Entry.
Each Record in the �Item Ledger Entry� table is an individual sale. The sales and Cost amount of this sales I calculated by summing the relevant �Value Entries�(Each value entry record is adds value to the Sales or cost amount of the relevant Item ledger entry).
When running the report to show sales total per customer the Quantity is added for every record in the value entry and not for every record in the item ledger entry, thus duplicating the value of quantity for every value entry record.
Tables:
� Customer:
o Customer Code, Customer Name
� Item Ledger Entry
o Entry No. , Posting Date, Customer Code, Quantity
� Value Entry
o Item ledger Entry No., Entry No., Sales Amount, Cost Amount
Joins:
� Item Ledger Entry � INNERJOIN(Many to One) � Customer WHERE Customer Code = Customer Code
� Item Ledger Entry � INNERJOIN(Many to One) � Value Entry WHERE Entry No. = Item Ledger Entry No.
Calculated Fields:
� Sales Quantity
o SUM(�Item Ledger Entry�.Quantity)
� Sales Amount(Actual)
o SUM(�Value Entry�.�Sales Amount�)
� Cost Amount Actual
o SUM(Value Entry�.�Cost Amount�)
Expected Report Results.
The report should show the Quantity sold and the summed Sales and Cost amounts per customer.
The Actual Results
For each record of the Value Entry Table the Qty. is summed hence if Value entry has more than one record related to the Item ledger entry, Quantity is duplicated for each record of Value entry.
I am attempting to create a Customer sales report which will display the total quantity, amount and cost of sales per customer for a period of time.
The Quantity is on the �Item Ledger Entry� table and the sales and cost amounts on the Value Entry.
Each Record in the �Item Ledger Entry� table is an individual sale. The sales and Cost amount of this sales I calculated by summing the relevant �Value Entries�(Each value entry record is adds value to the Sales or cost amount of the relevant Item ledger entry).
When running the report to show sales total per customer the Quantity is added for every record in the value entry and not for every record in the item ledger entry, thus duplicating the value of quantity for every value entry record.
Tables:
� Customer:
o Customer Code, Customer Name
� Item Ledger Entry
o Entry No. , Posting Date, Customer Code, Quantity
� Value Entry
o Item ledger Entry No., Entry No., Sales Amount, Cost Amount
Joins:
� Item Ledger Entry � INNERJOIN(Many to One) � Customer WHERE Customer Code = Customer Code
� Item Ledger Entry � INNERJOIN(Many to One) � Value Entry WHERE Entry No. = Item Ledger Entry No.
Calculated Fields:
� Sales Quantity
o SUM(�Item Ledger Entry�.Quantity)
� Sales Amount(Actual)
o SUM(�Value Entry�.�Sales Amount�)
� Cost Amount Actual
o SUM(Value Entry�.�Cost Amount�)
Expected Report Results.
The report should show the Quantity sold and the summed Sales and Cost amounts per customer.
The Actual Results
For each record of the Value Entry Table the Qty. is summed hence if Value entry has more than one record related to the Item ledger entry, Quantity is duplicated for each record of Value entry.
Hi Nick,
The way to get your expected results is to use an Append Sub-query in the following fashion:
1) Put the aggregated Quantity from the Item Leger Entry table in the main query
2) Put the other two aggregations from the Value Entry table in the Append sub-query and join the queries by the Entry number.
3) The results are what you want:
I hope that's what you were after, if not please don't hesitate to contact us.
Regards,
David
The way to get your expected results is to use an Append Sub-query in the following fashion:
1) Put the aggregated Quantity from the Item Leger Entry table in the main query
2) Put the other two aggregations from the Value Entry table in the Append sub-query and join the queries by the Entry number.
3) The results are what you want:
I hope that's what you were after, if not please don't hesitate to contact us.
Regards,
David
Hi David,
It worked.
A big thank you from me and the prospect. ;-)
Kind regards,
Nick
It worked.
A big thank you from me and the prospect. ;-)
Kind regards,
Nick