Solved

Crystal 10 formula for stock quantities from two tables

Posted on 2013-12-07
2
347 Views
Last Modified: 2013-12-11
Hello.
I have two tables invt.dat and strstk.dat

invt.dat stores information on inventory stock and strstk.dat stores information on which stores hold what stock quantities.

I want to create a report that lists stock and the holdings in each store.

invt.dat has one line in each table for each product line. It simply looks like this
SKU|Desc|Price
With data looking like this
070701|Red Box|2.50
070702|Blue Box|2.50

strstk.dat looks like this
SKU|Store|Qty

The data in strstk looks like this though
070701|01|1.00
070701|02|0.00
070701|03|3.00
070702|01|0.00 ....

So when I link the two tables by SKU the report I print gives me three lines per product when I really want this...

SKU|Desc|Price|QtyStore1|QtyStore2|QtyStore3

070701|Red Box|2.50|1.00|0.00|3.00
070702|Blue Box|2.50|0.00|.....

Can someone help me create a formula or solution that can yield this report?

Thank-you!
0
Comment
Question by:holdsworthbros
2 Comments
 
LVL 100

Accepted Solution

by:
mlmcc earned 500 total points
ID: 39704648
I can think of 3 ways to do this

You can do it with a cross tab, in the report through groups and summary formulas or you can do it through a Crystal command.

Crosstab
Insert a cross tab into the report header or footer
Right click the cross tab in the upper left corner
Click CROSSTAB EXPERT
Row - product
Column - store
summary - store qty

Group method
Add a group on the stock item
Add 3 formulas
Name - Store1Qty

If {Store} = 1 then
   {QtyField}
Else
   0

Name - Store2Qty

If {Store} = 2 then
   {QtyField}
Else
   0

Name - Store3Qty

If {Store} = 3 then
   {QtyField}
Else
   0

Insert the 3 formulas into the detail section
Right click each in turn
Click INSERT --> SUMMARY
Type SUM
Put it in the group footer
Click OK
Drag it to the group header

Repeat for each formula
suppress the detail section and the group footer

SQL method
Create a command as

SELECT Inv.SKU, Inv.Desc, ST1.Qty as St1Qty, ST2.Qty as ST2Qty, ST3.Qty as ST3Qty
FROM  ((invt Inv Left Outer Join strstk ST1 ON Inv.SKU = ST1.SKU and  ST1.Store = 1)
Left Outer Join strstk ST2 ON Inv.SKU = ST2.SKU and  ST2.Store = 2)
Left Outer Join strstk ST3 ON Inv.SKU = ST3.SKU and  ST3.Store = 3)

mlmcc
0
 

Author Comment

by:holdsworthbros
ID: 39707580
Gold!

I like the 2nd method, but I want to learn about cross tabs so will try that too.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

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

16 Experts available now in Live!

Get 1:1 Help Now