条件第一个参数的返回值,而无需重新计算

发布于 2025-02-12 09:42:57 字数 1951 浏览 5 评论 0原文

我知道我可以通过使用单独的单元格并使其不可见解决,但我想为此提供干净的解决方案,只使用1个单元格和1个公式。

对于此示例,我需要在x.00y.00(带小数)之间获得一个随机数,但不低于0.00而不是优于9.00。但是对于此示例,我仅使用1条条件来避免小于0.00简化的值。

我将使用randbetween()xy由虚拟文件上的其他两个单元格提供:b3d3

有时随机数可以小于0.00或更高的9.00的原因是我需要随机结果在随机+/- 1之间,而不是(x) +y)/2

xy值将有所不同。有时x将为3.54,有时8.99,对于y而言。对于情况时,发生xy是一个低号码,例如0.5 randbetween()函数可能会输出负数。因此,我需要输出为0.00。对于高值相同。如果Xy将接近9.00结果可能是9.35。在这种情况下,我需要输出为9.000。但是在下面的公式中,我仅使用低于零的情况来使其简单。

因此,我无法解决的问题是,我需要在不重新计算的情况下获得}条件的拳头参数的值。如果我参考false的第三参数,那么我将重新计算。我的公式是:

=IF(
    (RANDBETWEEN(
        ((((B3*100)+(D3*100))/2)-100),
        ((((B3*100)+(D3*100))/2)+100))
        /100)<0,0,
    (RANDBETWEEN(
        ((((B3*100)+(D3*100))/2)-100),
        ((((B3*100)+(D3*100))/2)+100))
        /100))

因此,这将检查第一个参数是否小于0.00,如果是显示0.00如果不是,则再次重新计算,这是一个问题,因为它有时可能会重新计算小于0.00的值。

我的问题是:有没有办法返回条件的第一个论点的价值,而无需重新计算randbetween()且不使用单独的单元格?

如果不可能,我也欢迎使用自定义气体功能进行任何解决方案。

我的虚拟文件:
https://docs.google.com/spreadsheets/d/15ytguvqdtuc-ramnjin-yg4j3uraorxdpiwty_kb_kb_k0/edit

(单击复选框重置,然后再次重新计算随机数)。

I know I can solve it by using a separate cell and make it invisible but I'd like a clean solution for this and use only 1 cell and 1 formula.

For this example I need to get a random number between X.00 and Y.00 (with decimals), not lower than 0.00 and not superior than 9.00. But for this example I am using only 1 condition for avoiding values less than 0.00 to simplify.

I will use RANDBETWEEN(). The X and Y are supplied by 2 other cells on the dummy file bellow: B3 and D3.

The reason why sometimes the random number can be less than 0.00 or above 9.00 is that I need the random result to be between random +/- 1 than (X+Y)/2.

Also X and Y values will vary. Sometimes X will be 3.54, sometimes 8.99 and same for Y. For situations when it happens that X and Y are a low number like 0.5 the RANDBETWEEN() function might output a negative number. When so I need the output to be 0.00. Same for high values. If both X and Y will be close to 9.00 the result might be something like 9.35. In this cases I´d need the output to be 9.000. But in the below formula I am only using cases below zero to make it simple.

So the problem I am unable to resolve is that I need to get the value of the fist argument of the ÌF() condition without recalculating it. If I refer to the 3rd argument for FALSE then I will recalculate. my formula is this:

=IF(
    (RANDBETWEEN(
        ((((B3*100)+(D3*100))/2)-100),
        ((((B3*100)+(D3*100))/2)+100))
        /100)<0,0,
    (RANDBETWEEN(
        ((((B3*100)+(D3*100))/2)-100),
        ((((B3*100)+(D3*100))/2)+100))
        /100))

So this will check if the first argument is less than 0.00, if it is it displays 0.00 if not it recalculates again and this is a problem because it might sometimes recalculate a value less than 0.00.

enter image description here

My question is: Is there a way to return the value of the first argument of the condition without recalculation of RANDBETWEEN() and without using a separate cell?

If not possible I would also welcome any solution using custom GAS functions.

My dummy file:
https://docs.google.com/spreadsheets/d/15YtgUVqDTuC-raMNJiN-YG4j3URaorXdPiwTy_Kb_K0/edit
(click checkbox to reset and again to recalculate the random number).

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

醉酒的小男人 2025-02-19 09:42:57

将您的randbetween Thook Thook Thook Thook Tookermin - max

=MAX(
  MIN(
   RANDBETWEEN(((((D3*100)+(B3*100))/2)-100),((((D3*100)+(B3*100))/2)+100))/100,
   9
  ),
 0
)*A1

Wrap your RANDBETWEEN within a MIN - MAX

=MAX(
  MIN(
   RANDBETWEEN(((((D3*100)+(B3*100))/2)-100),((((D3*100)+(B3*100))/2)+100))/100,
   9
  ),
 0
)*A1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文