crystal formula used to group

Stimulsoft Dashboards.WEB discussion
jgoswalt
Posts: 6
Joined: Mon Feb 10, 2020 4:40 pm

crystal formula used to group

Post by jgoswalt »

I have a formula that I have from a crystal report. Basically I have a database field that contains FirstName a space and LastName. I want to parse this field to get the last name and then use that to group/sort the report. This code is in a crystal formula called SortEmpLName. I then group the report on this field. Below is the original crystal code. How do I do this is Stimulsoft?


global stringvar lname:= "";
local numbervar i;

for i := Length ({AttendSumm.EmplName}) to 1 step -1 do
(
if Mid ({AttendSumm.EmplName},i ,1 ) = " " then
(
lname:= Mid ({AttendSumm.EmplName},i+1 ) + ", " + Left ({AttendSumm.EmplName},i - 1 );
exit for
)
);
lname
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: crystal formula used to group

Post by Lech Kulikowski »

Hello,

You can use the following expression:
{Substring(AttendSumm.EmplName, AttendSumm.EmplName.IndexOf(" "), AttendSumm.EmplName.Length)}

Thank you.
jgoswalt
Posts: 6
Joined: Mon Feb 10, 2020 4:40 pm

Re: crystal formula used to group

Post by jgoswalt »

Lech, I need to be able to search backwards, as some employee names have a middle initial. Using your above example I get:
Amy A. Bear
Joe E. Honious
Jack E. Reno
Jason Fray
john Isaacs
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: crystal formula used to group

Post by Lech Kulikowski »

Hello,

You can use a more complex expression to get the necessary result or prepare an additional column for grouping in data source.

Thank you.
jgoswalt
Posts: 6
Joined: Mon Feb 10, 2020 4:40 pm

Re: crystal formula used to group

Post by jgoswalt »

Still not sure how to do this? All I seem to get is the function name printing out. Any more help would be appreciated.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: crystal formula used to group

Post by Lech Kulikowski »

Hello,

You can use the following expression:
{Substring(AttendSumm.EmplName, AttendSumm.EmplName.LastIndexOf(" "), AttendSumm.EmplName.Length)}

Thank you.
jgoswalt
Posts: 6
Joined: Mon Feb 10, 2020 4:40 pm

Re: crystal formula used to group

Post by jgoswalt »

Example: "Anita A. Smith" or "Mark Brown"

{Substring(AttendSumm.EmplName, AttendSumm.EmplName.LastIndexOf(" "), AttendSumm.EmplName.Length)}

I have tried many variations of the above code and still no luck. It actually needs to be something like this, but this still does not work as it picks up the " " and give you " Smith" or " Brown"

{Substring(AttendSumm.EmplName, AttendSumm.EmplName.LastIndexOf(" "), AttendSumm.EmplName.Length - AttendSumm.EmplName.LastIndexOf(" "))}
or {AttendSumm.EmplName.substring(AttendSumm.EmplName.LastIndexOf(" "), AttendSumm.EmplName.Length - AttendSumm.EmplName.LastIndexOf(" "))}
When I use the above, it gives me the error of:

One or more errors occurred.
c:\Windows\Temp\ya3llnyk.0.cs(465,40) : error CS0103: The name 'substring' does not exist in the current contextc:\Windows\Temp\ya3llnyk.0.cs(465,98) : error CS1061: 'string' does not contain a definition for 'lastindexof' and no extension method 'lastindexof' accepting a first argument of type 'string' could be found (are you missing a using directive or an assembly reference?)


I also used another string function called instrrev. This works the way I want it to in vb.net, but gives me a similar error to above referencing substring and instrrev.

attendsumm.emplname.Substring(InStrRev(attendsum.emplname, " "), attendsumm.emplname.Length - InStrRev(attendsum.emplname, " "))

Help!! I am sure there is something simple that I am missing.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: crystal formula used to group

Post by Lech Kulikowski »

Hello,

Please send us a sample report with test data which reproduces the issue for analysis.

Thank you.
jgoswalt
Posts: 6
Joined: Mon Feb 10, 2020 4:40 pm

Re: crystal formula used to group

Post by jgoswalt »

I can't really do that. The report and database are in a package called E2-shoptech. I am just modifying one of the reports.
Lech Kulikowski
Posts: 6198
Joined: Tue Mar 20, 2018 5:34 am

Re: crystal formula used to group

Post by Lech Kulikowski »

Hello,

It is difficult to say something else about the issue without a sample. Please send the request to the E2-shoptech developers.

Thank you.
Post Reply