Crystal Reports. How to to extract only numbers before hyphen - crystal-reports

We have a number field in our Database called" {PO_TEMP_PO_HEADER.PO_Number}that contains numbers in the following format:
5418-4
1247-2
9134-1
I only want to display the numbers before the hyphen
5418
1247
9134
How do I do this in Crystal Reports?
I tried various formulas I found online but it always resulted in an error when saving in Crystal.

Split({your.db_column}, "-")[1];
This splits your column into an array and returns the 1st element.

Related

crystal report from dataset in c# has a lot of spaces on string fields

when creating crystal report from dataset in c# , some times the data in string fields appears not aligned and it seems have a lot of spaces before the text value .
please how can I remove all this spaces ?
you can use Trim function.
Trim(String database field)

Using LIKE in Multi-Value Parameter in Crystal Reports 2011

I am developing a report in Crystal Reports 2011 that has 3 sub-reports pulling data from 3 different databases. I have a Multi-Value Parameter (String) in the main report that passes the input values to the 3 sub-reports which have the same Multi-Value String Parameter.
Sample Input Values are:
P000000030,
P000000930,
P000001730
The user does not want to input the leading alpha character and preceeding zeroes. They want to input the following:
30,
930,
1730
The sub-report pulls all of the records successfully if the user puts the entire string value in with the following Record Selection Criteria, but it does not work with the partial strings input:
{Command.Puchase Order} in {?Pm-?Reference}
Can anyone advise the syntax needed to pull the data in the subreport with the substrings as inputs?
Thanks in advance!
Thank you for your input guys!! I took a bit from everyone and came up with the following solution:
Create a column in the datasource that trimmed out the desired value --> ltrim(regexp_replace(a."po_num",'P',''),'0') as "Puchase Order2"
Modified my Record Selection Criteria to select for either column --> {Command.Puchase Order} in {?Pm-?Reference} or {Command.Puchase Order2} in {?Pm-?Reference}
I really appreciate your input! I am able to deliver the desired solution with your aid.
go ahead and create a formula that calculate the length of your parameter(len({?Pm-?Reference})) and place it suppressed on your report header. Then put below in your record selection formula
right({Command.Puchase Order},{your length formula}) in [{?Pm-?Reference}]
You could add the "number only" version of [Puchase Order] to your datasource...
cast(cast(right([Puchase Order], len([Puchase Order]) - 1) as int) as varchar(9))
as [Puchase Order Number]
...then use that in the select expert. I'm getting the number without the leading P, casting to int to remove the leading zeros, and then back to a varchar for the string comparison in Crystal.
You could do the same with a formula in Crystal reports. Then reference that formula in the select expert. Downside is having to repeat that in all 3 sub reports.

How do I parse a field in Crystal Reports that uses a record separator

Crystal Reports XI, SQL Server 2008. I have a varchar column that uses a record separator to divide items but it disappears when it's rendered in Crystal Reports.
When I check the results in an editor I see that it's recognized as either RS or in Hex 1E. I would like to convert the RS to a comma if possible but anything that breaks it up would work.
Example Item oneRSItem TwoRSItem Three becomes Item OneItem TwoItem Three. I would like to have Item One, Item Two, Item Three.
Here's what I ended up doing which solved my issue. I determined that the record separator was CHAR(30) (using this table) and used that function in REPLACE(table.Value, CHAR(30), ', ') and it worked.

Display string formula not used when exporting from Crystal Reports XI

I've produced a report in Crystal Reports XI where I in one of the fields have used the display string formula to alter the apperance of some data as well as group similar data values to one value (e.g. "neg", "negative", and "-" now all displays as "negative" in the report.)
However, now when I export the report to CSV for delivery to a customer the raw data, and not the display string formula result, is in the export. I've tried all 4 settings with the checkboxes in the CSV export options.
Is there any way to make the display string formatted data beeing exported to the CSV?
Are there any alternate ways of achiving the desired formatting and getting the formatting preserved in CSV export?
Unfortunately, i've not found a way of using the display string formula and achieving the desired result.
Instead create a new formula and replace the object on the report with the new formula.
L

Crystal Report - Placing decimal point

I'm getting an integer value as 2345 but I want to display it as 234.5
is it possible??
To get what you are looking for in a simple fix is like what kingpin stated above. Divide the value by ten. To do this just create a new formula in crystal by going into your field explorer and right clicking on the formula fields section. Under there should be a option to create a new formula. Then in window that comes up put the field you want to manipulate in the formula and then divide that by ten. And there you go. Now use the formula field in the report instead of the original field.
Here is a example of how it could look.
{Table_Foo.value_Bar} / 10
There is a field property for it. Don't have access to crystal reports at the moment, but I know it's there:
Crystal Report Provides an easy to use default thousand separator for numeric Fields. You can use it by checking Thousand Separator from Field Properties.
If you need a customized separator, check Customized Thousand Separator in Crystal Report.
You also might want to find some tutorials on the Crystal Reports themselves if you still have trouble.