[Solved] Calculate first part at rate A, next part at rate B, rest at rate C

Discuss the spreadsheet application
Post Reply
andr3as
Posts: 2
Joined: Tue Oct 08, 2019 7:35 pm

[Solved] Calculate first part at rate A, next part at rate B, rest at rate C

Post by andr3as »

Hello Forum,

i am a bit stuck on that topic.. i have an issue calculating the following:

given a number in a cell (e.g. 5) it should calculate in another cell:
  • "the first 2" = 2*x*0.9
    "the next 2" = 2*x*0.4
    "the rest" = rest*x*0.2
examples:

lets say its 1:

1*x*0.9


lets say its 3:

2*x*0.9 + 1*x*0.4

lets make the 5 example explicit:

2*x*0.9 + 2*x*0.4 + 1*x*0.4

is this possible with a formula? if yes how? if not, is there another way?
Last edited by MrProgrammer on Tue Jan 10, 2023 8:21 pm, edited 1 time in total.
Reason: Tagged ✓ [Solved] -- MrProgrammer, forum moderator
thanks
Andreas

Libreoffice 6.3.2.2 on Manjaro Linux
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Is this even possible as a formula?

Post by Zizi64 »

What is the maximum value in the input cell?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
andr3as
Posts: 2
Joined: Tue Oct 08, 2019 7:35 pm

Re: Is this even possible as a formula?

Post by andr3as »

@Zizi64

thank you for your reply.. well, theoretically unlimited, practically it won't be much higher than 10 or 15..

however, as a heads up, it's not necessarily an integer.. it could as well be like 8.73 or something..
thanks
Andreas

Libreoffice 6.3.2.2 on Manjaro Linux
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Is this even possible as a formula?

Post by keme »

=X*0.2+MIN(X;4)*0.2+MIN(X;2)*0.5

Substitute the cell address for X.

Or did I misunderstand?
Last edited by keme on Tue Oct 08, 2019 9:14 pm, edited 1 time in total.
User avatar
Zizi64
Volunteer
Posts: 11361
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Is this even possible as a formula?

Post by Zizi64 »

well, theoretically unlimited, practically it won't be much higher than 10 or 15..

however, as a heads up, it's not necessarily an integer.. it could as well be like 8.73 or something..
And what are the expected results at these input numbers?
Tibor Kovacs, Hungary; LO7.5.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-7.6.2;AOO4.1.14
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
MrProgrammer
Moderator
Posts: 4908
Joined: Fri Jun 04, 2010 7:57 pm
Location: Wisconsin, USA

Re: Is this even possible as a formula?

Post by MrProgrammer »

Hi, and welcome to the forum.
andr3as wrote:2*x*0.9 + 2*x*0.4 + 1*x*0.4
What you you mean by x?
andr3as wrote:given a number in a cell (e.g. 5) it should calculate in another cell:
"the first 2" = 2*x*0.9
"the next 2"  = 2*x*0.4
"the rest"    = rest*x*0.2
I am interpreting your post to indicate that the "number in a cell" is never negative.
=SUMPRODUCT(cell>{0;2;4};cell-{0;2;4};{0.9;-0.5;-0.2}) * x
[Tutorial] The SUMPRODUCT function, X23
andr3as wrote:it's not necessarily an integer.. it could as well be like 8.73 or something.
The formula above will calculate whatever x is times 3.546 [2×0.9 + 2×0.2 + 4.73×0.2].

If this solved your problem please go to your first post use the Edit button and add [Solved] to the start of the title. You can select the green checkmark icon at the same time.

[Tutorial] Ten concepts that every Calc user should know
Mr. Programmer
AOO 4.1.7 Build 9800, MacOS 13.6.3, iMac Intel.   The locale for any menus or Calc formulas in my posts is English (USA).
Post Reply