Ask Your Question
1

how to sort fractions in a column

asked 2021-01-01 20:20:18 +0200

KAC352 gravatar image

updated 2021-01-01 20:41:24 +0200

I created a table and form to categorize router bits but when I entered the size they were not in numeric size order, is there a way to sort because sort ascending doesn't work. image description

Might be just as easy to start over too, any help appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2021-01-01 21:25:31 +0200

Ratslinger gravatar image

updated 2021-01-01 21:29:29 +0200

Hello,

Here I set the Size field to type Double in the table design. Then set the display type to Fraction (in table design or right mouse click wanted column):

image description

Now you can sort:

image description

edit flag offensive delete link more

Comments

(Since there is/was a bug in Calc concerning fraction formatting.)
For a side-interset: Are numerator and denominator specified/expected to be of an integer type here? Is this exclusively a matter of Base or is there database software offering fractional types?
Does Base use the same concept of NumberFormat as LibreOffice in general? If so, what object is parent of the NumberFormats container? The Form? The parent of the Forms?

Lupp gravatar imageLupp ( 2021-01-01 21:40:01 +0200 )edit

@Lupp,

Not certain I'll be able to satisfy your questions.

Are numerator and denominator specified/expected to be of an integer type here?

Yes. Any non-integer here will result in a value of 0.

Is this exclusively a matter of Base or is there database software offering fractional types?

Types used can be Numeric, Double or Float. There is no type Fraction.

The remainder I'm kind of lost with. It seems the concept may be the same (my educated guess) but the parent eludes me and where to look.

Ratslinger gravatar imageRatslinger ( 2021-01-01 22:26:12 +0200 )edit

@Lupp,

Here is link to data types available when using HSQLDB v1.8 embedded (included with LO and used in answer) -> Data Types.

Another here -> SQL Data Types for MySQL, SQL Server, and MS Access

Ratslinger gravatar imageRatslinger ( 2021-01-01 23:26:11 +0200 )edit

Sorry! I messed up my intended question completely. Of course numerator and denominator need to be integer values due to how we define fractions, and the part in front of the fraction is called the intehger part anyway. (The integer part was mainly my concern, but I missed to mention it.) However, if these three numbers are assigned during calculation to variables of an integer type, it is doubtable in principle if these variables can take the results based on Double (e.g.) calculations, or if they may overflow. (This was he background of the mentioned bug which seems to be fixed meanwhile - in a sense.)
An example: If the three numbers are sent to 32-bit integers, 2^32+1/5 cannot be shown in # ?/? format, despite the fact that it is well represented with sufficient accuracy in Double.
Also:2^32/5 cannot be displayed in ?/? because the numerator ...(more)

Lupp gravatar imageLupp ( 2021-01-01 23:27:15 +0200 )edit
Lupp gravatar imageLupp ( 2021-01-01 23:28:34 +0200 )edit

@Lupp,

Using your .ods file first line, entered 4294967296.2 in the database table and also got #FMT for a result.

4294967295.2 answered with 4294967295 1/5

Ratslinger gravatar imageRatslinger ( 2021-01-02 00:43:07 +0200 )edit

@Ratslinger: Seems to be the same as in Calc though the dialog is different.
Did you also check (2^32-1000)/5 (that's 858993259.2)?
Don't worry anyway. The bugfix announced by @erAck works as expected in V71.0.0.beta1.

Lupp gravatar imageLupp ( 2021-01-02 12:34:43 +0200 )edit

Thanks Ratslinger, when I did that when entering a fraction like 5/32 it drops everything but the fist number and when I first tried it changed fractions to a five digit number. What am I doing wrong?

I should have added that I deleted the original table and started over too.

image description

KAC352 gravatar imageKAC352 ( 2021-01-03 20:00:17 +0200 )edit

@KAC352,

There is no way to tell from what you have posted. Don't even know what field type or format you used. Did present steps in my answer - I set field type to double then display type (format) to Fraction. That's all that is needed. Only thing that may help is for you to post a sample. Edit your question and post it there.

Ratslinger gravatar imageRatslinger ( 2021-01-03 20:39:20 +0200 )edit

Not sure what I did before but started over and used your suggestion and it worked perfect Thanks Ratslinger

KAC352 gravatar imageKAC352 ( 2021-01-05 18:36:04 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2021-01-01 20:20:18 +0200

Seen: 53 times

Last updated: Jan 01