Print Page | Close Window

Exclude Part of Field Name

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=23011
Printed Date: 01 May 2024 at 5:17pm


Topic: Exclude Part of Field Name
Posted By: bjfils
Subject: Exclude Part of Field Name
Date Posted: 08 Aug 2022 at 10:11am
We're trying to automate a process in our manufacturing facility and want to group some data together in a Crystal Report based on data in a field. The issue the last character in the field name is irrelevant and we want to exclude it. Let's say the data is the field might be AB5X7IJKL1 and AB5X7IJKL2. The only difference is the last character in the data. I want to be able to group everything that is AB5X7IJKL together, ignoring the 1 or 2 at the end of the field. The data in the field will be 10 characters and the last character before the one I want to ignore will always be an L, which will never be elsewhere in the field.

I can group the report by the full unique data in the field, but haven't found a way to group by the first 9 of the 10 characters in the field. It's probably an easy fix, but I only know enough about Crystal to be dangerous.

Thanks!



Replies:
Posted By: hilfy
Date Posted: 23 Aug 2022 at 6:49am
Try creating a formula like this and then grouping on it:


Left({MyTable.MyField}, 9)


If there are some records where you need to look for the L and don't want to strip off the last character if the L isn't there, you could use a formula like this:

if InStr({MyTable.MyField}, 'L') = Length({MyTable.MyField}) - 1 then
Left({MyTable.MyField}, Length({MyTable.MyField}) - 1)
else
{MyTable.MyField}


-Dell

-------------
Proviti, Data & Analytics Practice
http://www.protiviti.com/US-en/data-management-advanced-analytics - www.protiviti.com/US-en/data-management-advanced-analytics


Posted By: bjfils
Date Posted: 23 Aug 2022 at 9:23am
Thanks. I'll give that a shot. I found a workaround that's a little kludgy, but works.



Print Page | Close Window