# Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

New Contributor III

## How to Use Mid with Min Function

Hello Everyone!

So I have this field which contains a code and within that code there is a year (e.g. XXYYYYZZZZZ, where YYYY represents the year).

So what I would like to do is to get the minimum year after extracting it from that field. I have tried the following:

Min(Mid(Code, 3, 4))

Min(aggr(Mid(Code, 3, 4), ID))

But it doesn't work.

Your help is appreciated.

1 Solution

Accepted Solutions

## Re: How to Use Mid with Min Function

With these informations it's quite difficult to say what didn't worked like expected. Maybe it's easier to extract this within the script:

Num(Mid(Code, 3, 4)) as CodeYear

Are the other code-parts not numeric you could also use: keepchar(Code, '0123456789'). And then should be a min() or a firstsortedvalue() expression within the charts simpler.

- Marcus

3 Replies

## Re: How to Use Mid with Min Function

With these informations it's quite difficult to say what didn't worked like expected. Maybe it's easier to extract this within the script:

Num(Mid(Code, 3, 4)) as CodeYear

Are the other code-parts not numeric you could also use: keepchar(Code, '0123456789'). And then should be a min() or a firstsortedvalue() expression within the charts simpler.

- Marcus

MVP

## Re: How to Use Mid with Min Function

Where exactly are you trying to do this? In the script? In an expression may be like this

Min(Year(Date#(Mid(Code, 3, 4), 'YYYY')))

New Contributor III

## Re: How to Use Mid with Min Function

Sorry didn't work.