Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Return Last String in field - using expression

I want to return the last string in a field of data. What expression would i use to do that?

e.g.

Cost

100

200

170

the expression i want would return 170

Thanks In Advance

4 Replies
Not applicable
Author

Hi, try this one:

=FieldValue('Cost',FieldValueCount('Cost'))

it is really important that you use single quotations. i've tested it on a text object expression

Not applicable
Author

Apologies. that was unclear, your response works to a certain extent.

i am looking to group rows of data with the same reference ( see below )

Ref Cost

1 100

1 200

1 170

2 150

2 160

2 200

Would return

1 170

2 200

spividori
Specialist
Specialist

Hi!

See the example.

Regards.

Not applicable
Author

Hello MITeamEldon,

I'm not quite certain if you want it in the script or in a sheetobject.
But here is my suggestion for a script:

//testdata:
tbl:
LOAD * INLINE [
Ref, Cost
1, 100
1, 200
1, 170
2, 150
2, 160
2, 200
];

//now load the data again,
//and find the last value of Cost per Ref
tblsum:
load
Ref,
LastValue(Cost)
resident tbl
group by Ref;

drop table tbl;

Best regards