Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

no information when nothing is sold

Status
Not open for further replies.

henky

Programmer
Jul 20, 2000
56
NL
Hello All<br><br>Firstly I have to tell that I am from Holland and that English isn't my main language, so you know why some<br>sentences or words aren't clear to you. (all apologies for that:)<br><br>I am using CR v8.0 (for 2 months now.) I have to make a report about what we sold over the last 30 days. In the<br>report 4 different tables are being used.(all dbf format which are linked right). When there is something sold #Table1 and #Table2 will be used. #Table1 will be used for showing some information regarding that title, next to this #Table2 is used to give the total  price and sum of how many<br>products are being sold of that title. If nothing is sold of a title a problem appears because the information in Nr.2 (see attachment) of the title will not be shown when nothing has been sold! I wish I could see that if there isn't sold anything this would result at a title: The name of the title from #Table1 and  "0" in the row "how many<br>products are sold of this title" and a $ 0.00 in the row "what is the profit of this title".<br><br>It seems like this<br><br>Nr.1    #Table1 #Table1<br><br>301098   PV 7.1a   18.0%<br>301123   PV 7.1b     7.0%<br>301176   PV 7.1c   10.0%<br>301177   PV 7.1d     6.0%<br>301178   PV 7.5a   10.0%<br>301179   PV 7.5b     8.0%<br><br>The 6 lines with information (T1) is only about #Table1. These 6 Titles must be shown in T2 but if there is nothing sold of 301176, 301177 and 301178 these titles will not be  shown. How can I get the T2 the same like T3<br>(T3 is handmade now)<br><br>Nr.2   #Table1 #Table1 #Table2       #Table2<br><br>301098   PV 7.1a   18.0%   13      $ 1,072.50 <br>301123   PV 7.1b     7.0%   19      $ 1,057.12 <br>301179   PV 7.5b     8.0%   11      $    775.28 <br><br>It must be like this way<br>(T3 is handmade now) (T3 is handmade now) <br><br>Nr.3 <br><br>301098   PV 7.1a   18.0%   13      $ 1,072.50 <br>301123   PV 7.1b     7.0%   19      $ 1,057.12 <br>301176   PV 7.1c   10.0%     0      $        0.00<br>301177   PV 7.1d      6.0%    0      $        0.00<br>301178   PV 7.5a    10.0%    0      $        0.00<br>301179   PV 7.5b      8.0%  11      $     775.28<br><br>Any help would be greatly appreciated.<br><br>Henky
 
One of the main reasons why this could be happening is the logic in linking.&nbsp;&nbsp;If you linked using Left Outer Join, it will display rows from Table 1 only if it matches the rows from Table 2.&nbsp;&nbsp;You could make a copy of the report, change the link to equi join and see if it brings back the rows with 0 quantity and price.&nbsp;&nbsp;Of course, this may cause some other side effects which you will have to test for.<br><br>If you can't change the join, one way to remedy this is create 2 formulas, &quot;substitute0Quantity&quot; and &quot;substitute0Price&quot;, with the logic to evaluate the row to gage if table2.quantity and table2.price are null or zero.&nbsp;&nbsp;If both are 0, assign the field value of zero, otherwise, do nothing.&nbsp;&nbsp;This will enable the field to be displayed on your report.&nbsp;&nbsp;Place this field instead of displaying the database field directly on the report.<br><br>&nbsp;<br><br>e.g. to substitue quantity<br>//if the quantity and price are null<br>If <br>(table2.quantity = ' ' or isnull(table2.quantity)) <br>and (table2.price = ' ' or isnull(table2.price)<br><br>//then assign zero value to quantity<br>then<br>table2.quantity := 0 <br><br>//else, do nothing<br>else<br>table2.quantity := table2.quantity <br><br><br><br>
 
Oops!&nbsp;&nbsp;Error in the formula.&nbsp;&nbsp;The correct example is:<br><br>e.g. to substitue quantity<br>//if the quantity and price are null<br>If <br>(table2.quantity = ' ' or isnull(table2.quantity)) <br>and (table2.price = ' ' or isnull(table2.price)<br><br>//then display zero <br>then<br>0 <br><br>//else, do nothing<br>else<br>table2.quantity ;
 
Hi Ina,<br><br>Thanx for the helping hand (formula)<br>I have only one problem when I check the formula on fouls I have two fouls (both the same). The cursor is standing before the two quotes (' ') and the error says <font color=red>A number is required here.</font> I use Crystal Reports for quit a short time, so I don't know everything about it :(&nbsp;&nbsp;but I think the format or the field is the problem<br>Can you help me again? <br><br>Henky
 
Hi Henky,<br>&nbsp;&nbsp;&nbsp;If 'table2.quanity' is declared as a number try putting a zero instead of ' '. <p>LindaC<br><a href=mailto:lcastner@co.orange.ny.us>lcastner@co.orange.ny.us</a><br><a href= > </a><br>
 
Hi LindaC,<br><br>Thanks for the information. But :( I already tried that and it wont work. If there is nothing sold of a title, it wont be noticed, so there is nothing standing in Table2 about that title, so there is no ZERO ((thats why Ina used that ' ' I think)) There's just nothing.<br><br>Henky<br>
 
Hi Henky,<br>&nbsp;&nbsp;&nbsp;Have you tried a left outer join between the tables?&nbsp;&nbsp;I am not sure if you can with .dbf files.&nbsp;&nbsp;I am used to SQL tables.&nbsp;&nbsp;But, the following is straight from Crystal Report Online Help (just search for 'join'):<br><br>&quot;The result set from a Left Outer join includes all the records in which the linked field value in both tables is an exact match. It also includes a row for every record in the primary (left) table for which the linked field value has no match in the lookup table.&quot; <p>LindaC<br><a href=mailto:lcastner@co.orange.ny.us>lcastner@co.orange.ny.us</a><br><a href= > </a><br>
 
Henky,<br><br>Have you tried using just IsNull(table2.quantity) and leaving out table2.quantity = ' ' (or '')?&nbsp;&nbsp;The reason for this second part is if the IsNull formula does not catch all the records for some reason.<br><br>Funny thing, I just went back and checked my IsNull(date) formula that was created in version 6.&nbsp;&nbsp;It used to display o's for date and then sort properly, but now, in version 7, this formula does not display 0's but does sort correctly. <br><br>If the IsNull alone does not work, try assigning variables and see if that makes any difference.<br><br>e.g <br>numbervar qnt;<br><br>//if the quantity and price are null<br>If <br>(isnull(table2.quantity)<br>and isnull(table2.price))<br><br>//then assign zero to variable<br>then<br>qnt := 0; <br><br>//else, assign value to variable<br>else<br>qnt := table2.quantity ;
 
Blundered again:<br><br>The only way my rows are coming through from table 2 when there is no matching record from table 1 is because I DO USE left outer join.<br><br>Sorry!<br>
 
LOL,<br><br>I don not use SQL and that's why I cannot use <font color=blue>left outer join </font> in my formula. So I still have a problem. Do you know how I can show the 0 when I am using some dbf files?<br><br>Henky<br>
 
How about creating a formula for quantity checking: <br><br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;if table2.productid &gt; table1.productid then<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;quanity := 0<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;else<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;quanity := table2.quanity.<br><br>Then create formulas for the other fields you need.&nbsp;&nbsp;&nbsp; <p>LindaC<br><a href=mailto:lcastner@co.orange.ny.us>lcastner@co.orange.ny.us</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top