cancel
Showing results for 
Search instead for 
Did you mean: 

Select portion of a field

Former Member
0 Kudos

I looked this up and I did not find any threads that talked about this.

Can any one post an example of a running total formula that only looks for a portion of the field.

I have a field that is {CAWP.WP} in the fiels the text string is 10120430.100 tru .900 ect

I need to omly select the .900 prtion of the field to return the desired report number

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi John

Create a formula like this..

mid(,1,len()-4)

This will work only if the lenght of the fields that you want to extract is constant.

Hope this helps.

Regards

Ankeet

Answers (3)

Answers (3)

Former Member
0 Kudos

I think I may have mis-explained my problem.

I inserted a running total to reevaluate after each project number i.e. 10120000

the .100 thru .900 is the code that each of my resources have i.e. 10120000.100 etc.

I am using this field to only evauluate for the .900 so getting the last four didgits is not what i need

the running total sums CAWP.BAC which is the cost of each resource

it (at this time) evaluates with this formula ( I think this is wrong): "900" In {CAWP.WP}

and i have it reseting after group 3.

the problem is how do I tell it to only evaulate "900" out of the CAWP.WP string?

Former Member
0 Kudos

If you only need the portion of the field that is after the period (".") then why not simply do this:

split(,'.')[2];

This will give you 900 every time regardless of the length.

Former Member
0 Kudos

No my field length is not constant. Any other thoughts?

Former Member
0 Kudos

Hi John

The above formula will work even if your field lenght is not constant, however it will not work if the number of characters that you want to extract is not constant throughout.

Eg. If you want to extract last 4 characters from the field each time it will work. If this lenght varies it will not work.

Regards

Ankeet

Former Member
0 Kudos

Hi John,

Use this for loop it will work better for your string.

Local StringVar str := "";
Local NumberVar strLen := Length ({Field Name});
Local NumberVar i;
Local NumberVar j;

For i := 1 To strLen Do

(

    if {Filed Name} <i> = "." then
        For j := 1 To strLen Do
        (
            i:=i+1;
           if {Filed Name} <i> = " " then exit for;
            str:= str + {Filed Name} <i>;
            j:= j+1;
        );
);
str

This will solve your problem.

Thanks,

Ashok