Ragome
Ragome

Reputation: 75

How to sort the following numbers in ascending order?

I would like to seek for your help.

I have these values in a view (ascending)

10D
11R
8A
8B
9C

But I want it to output the values in the "digit" dialog box in this manner:

8A
8B
9C
10D
11R

I tried using a hidden column (ascending order) having this as the code but it's getting error.

@length(digit)

Do note that the view has many forms associated to it.

Can you please help me?

Upvotes: 0

Views: 133

Answers (2)

Newbs
Newbs

Reputation: 1632

I seems like you need the sort for the items with number prefixes to be G1, G2, G3, G4 ...G11, G12, etc. I would add a hidden sort column to the view with something like this:

wkey := SortKey;
lnum := @TextToNumber(@Left(wkey;1));

@If(@IsError(lnum); @Do(
    ch := @Left(wkey; 1);
    npart := @Right(wkey; ch);
    @Return(ch + @Right("00" + npart; 2))
); @Do(
    ch := @Right(wkey;1);
    npart := @Left(wkey; ch);
    @Return(@Right("00" + npart; 2) + ch))
);

Upvotes: 1

OliC
OliC

Reputation: 175

you could try it with 2 hidden column. If the field has the Name "id", for teh the first hiden column you use the formula @toNumber(id). If you have also values which begin with a character you can use this Formular for the first hidden column

@If(@Contains(@Text(@ToNumber(id));"Text");@Text(@ToNumber(id)) + id;@ToNumber(id))

This case is not shown in the Picture belos

For the second hidden column you use the formula @Text(id). And in the column which you want see, you Show the Field id.

the view, the first two column you shuld hidden

first hidden column

second hidden column

column you want display

Upvotes: 0

Related Questions