Topic: Exclude Part of Field Name 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.
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
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}
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum