Bug 165136 - Enhance ROUND function(s) to handle a run of multiple-number values
Summary: Enhance ROUND function(s) to handle a run of multiple-number values
Status: RESOLVED WONTFIX
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
unspecified
Hardware: All All
: medium enhancement
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Calc-Function
  Show dependency treegraph
 
Reported: 2025-02-08 18:33 UTC by shoe200
Modified: 2025-02-08 19:24 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description shoe200 2025-02-08 18:33:13 UTC
Description:
These are possible school notes: 1.0, 1.3, 1.7, 2.0, 2.3, ..... 4.3, 4.7, 5.0.
The note 2.6 needs to be rounded up to 2.7, 2.9 up to 3.0, etc.
It would be nice to have a ROUND funcion like:
ROUNDFREE(1;1;1.3;1.7;.....4.7;5)
The first number can be 1 to round up or -1 to round down, followed by a list of individual numbers. 
Nice to have: the number of digits is free, like:
ROUNDFREE(-1;3.3309;14.09;-19.0008)
Probably you need a further parameter to decide how to handle number that is out of range, like to round 8.3 up to 5

Actual Results:
Enhancement Request!

Expected Results:
EnhEnhancement Request!


Reproducible: Always


User Profile Reset: No

Additional Info:
Enhancement Request!
Comment 1 Buovjaga 2025-02-08 19:01:11 UTC
Can you change the summary to something proper? Thanks.
Comment 2 Mike Kaganski 2025-02-08 19:13:05 UTC
Round down is easy.

Cells A1:A20: 1.0, 1.3, 1.7, 2.0, 2.3, ..... 4.3, 4.7, 5.0

Formula to round down a number in cell B1:

=VLOOKUP(B1;A1:A20;1;1)

This can also be entered using inline arrays, without the values in A1:A20 (although this is a worse idea methodologically: having a dedicated dictionaries is a good method):

=VLOOKUP(B1,{1;1.3;1.7;2;2.3;...;4.3;4.7;5},1,1)

Round up can be implemented in a similar way, using XLOOKUP, available since LibreOffice 24.8; it allows to specify, if the function should return the next smaller or the next larger value.

These functions provide 100% of the functionality that you are looking for. No need for dedicated "round" functions, that implement a subset of the existing functions.

By the way: you did it correctly, posting your enhancement request here: we track both bugs and enhancements here, using the "severity: enhancement".

Ref:

https://help.libreoffice.org/latest/en-US/text/scalc/01/04060109.html?DbPAR=CALC#bm_id3153152

https://help.libreoffice.org/latest/en-US/text/scalc/01/func_xlookup.html?DbPAR=CALC
Comment 3 V Stuart Foote 2025-02-08 19:22:56 UTC
Guess a enhanced ROUND would be LibreOffice extended beyond ODF 1.4 spec for Formula provided ROUND, ROUNDUP and ROUNDDOWN [1].

=-ref-=
[1] https://docs.oasis-open.org/office/OpenDocument/v1.4/csd01/part4-formula/OpenDocument-v1.4-csd01-part4-formula.html#__RefHeading__1018614_715980110