Bug 139985 - Problem with rept() in combination with randbetween.nv()
Summary: Problem with rept() in combination with randbetween.nv()
Status: NEW
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
7.0.2.2 release
Hardware: All All
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: Cell-Formula Calculate
  Show dependency treegraph
 
Reported: 2021-01-28 23:17 UTC by Joachim Kreutzer
Modified: 2025-09-02 03:14 UTC (History)
5 users (show)

See Also:
Crash report or crash signature:


Attachments
Calc-file, which shows in cell A1 the rept -problem (8.44 KB, application/vnd.oasis.opendocument.spreadsheet)
2021-01-28 23:22 UTC, Joachim Kreutzer
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Joachim Kreutzer 2021-01-28 23:17:03 UTC
Description:
Cell A1: =REPT("a";B1)
Cell B1: =RANDBETWEEN.NF(1;10)

Safe and open the file and you see, the A1 the error in A1

Steps to Reproduce:
1. Cell A1: =REPT("a";B1)
2. Cell B1: =RANDBETWEEN.NF(1;10)
3. Safe and open the file and you see, the A1 contains wrong number of 'a'.

Actual Results:
Example
Cell B1 contains 8
Cell A1 contains "aa"

Expected Results:
Cell B1 contains 8
Cell A1 contains "aaaaaaaa"


Reproducible: Always


User Profile Reset: No



Additional Info:
While RANDBETWEEN.NF is recalculated by opening the calc-file, the cell with rept won't be updated.
Comment 1 Joachim Kreutzer 2021-01-28 23:22:32 UTC
Created attachment 169253 [details]
Calc-file, which shows in cell A1 the rept -problem

Please open the file and you see the problem immediatly in cell A1 versus A2.
Comment 2 Julien Nabet 2021-01-29 16:44:04 UTC
Assignee field is for those who work on a bug fix, is it your intention or just a mistake?
Also don't confirm your own bug.

On pc Debian x86-64 with master sources updated today, I got the same behavior as reported. Now I'm not an expert but not sure if it should really change each time you open Calc.

Let's wait feedback from other QA people or Calc experts.
Comment 3 m_a_riosv 2021-01-29 18:37:59 UTC
In A2 NOW() function that it's volatile forces the calculation.
But not clear to me why REPT() is not calculated and RANDBETWEEN.NV() is.
And not matter in which cell REPT() is put.
Deleting the cell with NOW() ind, doesn't solve the issue, even more in this case [F9] only works if you are in the cell with REP().

Looks to me like some kind of bug.
Comment 4 BogdanB 2021-01-30 06:36:25 UTC
It is working with Data - Calculate  - Recalculate Hard, OR Shift+Ctrl+F9, but I don't say that is not a bug. Maybe it should be automatically recalculated.


Version: 7.0.4.2
Build ID: dcf040e67528d9187c66b2379df5ea4407429775
CPU threads: 4; OS: Linux 5.8; UI render: default; VCL: gtk3
Locale: ro-RO (ro_RO.UTF-8); UI: en-US
Calc: threaded
Comment 5 ady 2023-09-02 19:18:18 UTC
NOW() is a volatile function; REPT() is not.

RANDBETWEEN.NV() is not a volatile function either, but it is recalculated under certain circumstances such as when opening the file (see help content).

You could modify menu Tools > Options > LibreOffice Calc > Formula > Recalculation on File Load, or manually use Data > Calculate > Recalculate Hard ([CTRL]+[SHIFT]+[F9]), but these might not be enough when sharing the file.

Or instead of
=REPT("a";B1)

...you add some volatile function. For instance (just as a generic example):
=REPT("a";B1)&T(NOW())

If you have to use this method on multiple cells, you could have:
C1: =T(NOW())
A1: =REPT("a";B1)&$C$1

...and re-use "&$C$1" (or "+$C$1" on numeric functions/cells) on each relevant cell.

These methods would force the recalculation on that/those specific cell(s).

Each alternative has its own pros and cons.

Another possibility would be to use the RANDBETWEEN.NV() function as the second argument of REPT(), but that would be only useful when there are no other cells that would need to depend on the same resulting value of the same RANDBETWEEN.NV() function. When multiple cells must depend on the _same_ result of the RANDBETWEEN.NV() function, this alternative would not be a valid approach.
Comment 6 ady 2023-09-02 19:28:50 UTC
OTOH, RANDBETWEEN() _is_ a volatile function, so you might just use that instead of RANDBETWEEN.NV().
Comment 7 ady 2023-09-02 19:43:30 UTC
There is one additional POV for this report; which is the possible need/desire to recalculate RANDBETWEEN.NV() only once when the file is loaded (or for whichever event the function is normally recalculated), and _then_ recalculate any dependent cells.

I guess that such approach would make this an enhancement request for some additional option or some kind of new variant on RANDBETWEEN.NVxx().
Comment 8 QA Administrators 2025-09-02 03:14:00 UTC
Dear Joachim Kreutzer,

To make sure we're focusing on the bugs that affect our users today, LibreOffice QA is asking bug reporters and confirmers to retest open, confirmed bugs which have not been touched for over a year.

There have been thousands of bug fixes and commits since anyone checked on this bug report. During that time, it's possible that the bug has been fixed, or the details of the problem have changed. We'd really appreciate your help in getting confirmation that the bug is still present.

If you have time, please do the following:

Test to see if the bug is still present with the latest version of LibreOffice from https://www.libreoffice.org/download/

If the bug is present, please leave a comment that includes the information from Help - About LibreOffice.
 
If the bug is NOT present, please set the bug's Status field to RESOLVED-WORKSFORME and leave a comment that includes the information from Help - About LibreOffice.

Please DO NOT

Update the version field
Reply via email (please reply directly on the bug tracker)
Set the bug's Status field to RESOLVED - FIXED (this status has a particular meaning that is not 
appropriate in this case)


If you want to do more to help you can test to see if your issue is a REGRESSION. To do so:
1. Download and install oldest version of LibreOffice (usually 3.3 unless your bug pertains to a feature added after 3.3) from https://downloadarchive.documentfoundation.org/libreoffice/old/

2. Test your bug
3. Leave a comment with your results.
4a. If the bug was present with 3.3 - set version to 'inherited from OOo';
4b. If the bug was not present in 3.3 - add 'regression' to keyword


Feel free to come ask questions or to say hello in our QA chat: https://web.libera.chat/?settings=#libreoffice-qa

Thank you for helping us make LibreOffice even better for everyone!

Warm Regards,
QA Team

MassPing-UntouchedBug