One field in a Crystal Report with a different Select than the rest of the report - select

I have a table that has a primary key which is a combo of 2 fields:
ITEM_NO and
LOC_ID
I have a a report made that shows me all the results of an ITEM_NO based on LOC_ID that is chosen. So lets say for all items, show me all the fields I need to see where LOC_ID = '1'
This is set up in the select record section, however, there is one particular field (BIN_1) per record that I want displayed which should show me the value based on LOC_ID = '3', no matter which LOC_ID is set in the select expert parameter.
So, even though all the fields on the report show values Where LOC_ID = '1', the BIN_1 field should show the value where LOC_ID = '3' regardless of the parameter set for the rest of the report
I tried this by creating a new formula field in the report with a where clause, but this doesnt seem to work. Anyone here have any better ideas

You may add the table you are selecting from a second time to your report. Maybe rename it to something like "table_loc3". (Inner-) Join "table_loc3" to your original table on ITEM_NO. Add a record selection criteria for "table_loc3" and filter LOC_ID to be 3.

Related

Oracle APEX calculated field is not shown on the report

In my report I am pulling data from 2 tables and I want to display a calculated column. If I run the query in SQL Workshop, it works as desired but in the report calculated column does not get displayed.
Can annyone tell me what am I doing wrong? Perhaps there is a better way to accomplish what I want?
select "T1"."Table2_ID",
"T2"."Title",
"T1"."PRICE",
"T1"."QTY",
TO_CHAR("T1"."QTY" * "T1"."PRICE", '$999.99') AS TOTAL_PRICE
from "Table1" "T1",
"Table2" "T2"
where "T1"."Table2_ID" = "T2"."ID"
Column type on the report is listed as plain text.
Is it an interactive report? If so,
run the report
go to "Actions" menu
Columns
include the newly added column into the displayed column list
If not, what is it?

iReport multiple copies of same report with different label

I am using iReport 4.1.3. I have created invoice report and I want to have 3 copies of same invoice report. The first invoice should have label as "ORIGINAL", second should have "DUPLICATE" and the third should have label as "TRIPLICATE" on it.
Thank you.
If you would like to show all three copies every time you open the report, here is a creative if not elegant solution.
Add a cross join to the FROM clause of your query returning the three different copies. In MySQL it looks like this:
CROSS JOIN
(
Select 'ORIGINAL' as copy, 1 as sequence
UNION
SELECT 'DUPLICATE' as copy, 2 as sequence
UNION
SELECT 'TRIPLICATE' as copy, 3 as sequence
) x
Then add the "copy" field to your select statement. This will cause your query to return 3 records for each record it was previously returning. One record with "ORIGINAL" in the copy field, one with "DUPLICATE" and one with "TRIPLICATE". Add "sequence" to your ORDER BY clause.
Then in the report, group by the "copy" field. Force a new page for each group and you should be all set. Any variables you are totaling at the report level you will need to change to the group level ("copy" group). And if you have any controls in the Summary section, move them to the new group footer section. Also create a text field to display the "copy" field in the page or group header.
It's not necessarily pretty, but it should work.

Is there a way to select records from text parameters after run time in Crystal Reports?

I need to design a crystal report with 3 columns. Column 1 is a text box in the report, and column 2 and column 3 are datafields from a particular table.
Is it possible for me to use column1 as a parameter that would help me to fetch the other columns from the database??
col1 col2 col3
TextBox value1 value2
so when a user changes the value in TextBox, col2 and col3 value should reflect based on textbox value.
Or is there any other way in which i can achieve this??
There is no way to interact with a report the way you want via text boxes after the report has run. Since you can't select records on the fly, you'll have to create a report parameter of the same type as your primary keys (column A) and then set it to "Allow multiple values". You'll be able to select only the records you're looking for at run time by adding {table.colA} in {?Parameter1} into your Record Selection formula.
Drop {table.colA} and {table.ColB} into the Details section of the report. Now when you run it you can just add your 15 items as the parameter and you'll get what you're looking for.
Alternatively, if its important for the user to interact with the report after it's presented, you could accomplish this using (1) sections/grouping and Crystal's Hide option or (2) an on-demand subreport.
For example, you could group by column1, and then print a detail section for all the values. Mark the detail section Hide. Then, when you click on the value, that section will expand.
Or instead of marking it Hide, mark the group footer (for column1) New Page After Section. Then you can use the document tree along the left side to navigate to the page containing the values you're interested in seeing.

What could cause a drop down list (select) to ignore its Value field?

I've got a report that has several parameters, among them CompanyID. The available values come from a dataset with the Value field set to "Value" and the Label field set to "Label". Not exactly Rocket Science. The query looks like this:
select null as Value, ' Any' as Label
union all
select CompanyID as Value, CompanyName as Label from core.Companies
order by Label
Ok, no surprises. When I run that query I get things like
1506 Amalgamated Steel
2341 Beson Industries
245 Carver Holdings
etc....
Looks fine. However, when I view the HTML generated in report viewer, the select element that is generated has ordered integers for values: 1,2,3,4 etc. so filtering the results by company ID isn't working.
What could cause this? The query is returning the correct values, the values are being populated in the dropdown, the Value field for the param is set to the Value field from the query. They just don't have the correct value in the select/option field.
I cannot reproduce this in reporting services, it is working exactly fine for me.
My query is similiar although I always want the value "All" or "Any" as you mentioned to be at the top of my list so users dont have to look for it. I also do not include null as a value, I translate null to the value 0:
SELECT
1 As SortOrder,
CompanyID as Value,
Company as Label
FROM
Core.Companies
UNION ALL
SELECT
0 as SortOrder,
0 as Value,
"All" as Label
ORDER BY
'bring all / any to the top
'then order the rest by company name
SortOrder,
Label
This ensures the null is not included in the result list...then in my main query the query that pulls the data, when I want to filter for the company id or all I do this:
SELECT
...
FROM
Mytable
WHERE
CompanyID = #CompanyID OR #CompanyID = 0 'handle one customer or all customers
The report works fine and my select has the correct values...

How to show empty groups in crystal?

I have a report that shows items by goups.
Lets say he groups are:
In Inventory
In Process
When there is no data In Inventory, that row is not shown. any idea how to show a row with 0 inventory?
It sounds as though you are grouping on a field (such as stock item status), where there may be 0 rows returned for certain values of the field (such as In Inventory). The answer is to amend your query to right outer join to a lookup table holding all values of the grouping field, for example as follows:
select lu.status_value stock_item_status,
si.stock_item_status item_status,
si.stock_item_id,
coalesce(si.quantity,0) quantity
from stock_item si
right join stock_item_status lu
on si.stock_item_status = lu.status_value
This will now include a row returned for stock_item_status values with no corresponding stock_items, with null values for all of the stock_item fields.
If you were including a subtotal of stock_item.quantity values for each status, changing this to coalesce(...,0) should ensure that this null value is displayed as 0.
If I'm understanding you correctly, you've got a field {table.inventory} that holds the number of items in inventory that has a null value when the inventory is zero? When you group on this field you're not seeing the rows with null values in this field?
Crystal should still display those rows, just in a group with a null group name. To fix this you can go into the Group Expert -> Select the group in question -> Options -> Options tab -> Select 'customize group name field' -> and then specify a formula as a new group name field where you simply check to see
if isnull({table.inventory}) then 0 else {table.inventory}
Similarly, you can just create a formula that does this and group on that instead.