Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
242 views
in Technique[技术] by (71.8m points)

excel - How to combine 2 separate formulas based on additional criteria

I have 2 lines of code which both work well separately helping me to calculate staking, but I need to have both lines work in a single cell, but depending on additional criteria. For the life of me I haven't been able to get it to work Code 1

=IF(F19="","",IF(F19<3.5,L18*0.01,IF(F19<7.45,L18*0.006,IF(F19<11.1,L18*0.004,"0"))))

Code 2

=IF(F19="","",IF(F19<3.5,$M$18*0.01,IF(F19<7.45,$M$18*0.006,IF(F19<11.1,$M$18*0.004,"0"))))

What I need to try and do is have code 1 work IF L19>$M$18 and code 2 work IF L<=$M$18

I have tried many combinations of IF, AND and OR (over 2 hours so far), but can't seem to crack it. I keep getting "too many arguments" error messages

I haven't even been able to put just one side of the equation together with the required criteria

=IF(AND(F19="","",L19>$M$18,IF(F19<3.5,L18*0.01,IF(F19<7.45,L18*0.006,IF(F19<11.1,L18*0.004,"0")))))

If anyone can spot my obvious errors, I would appreciate your input

Thanks in advance

question from:https://stackoverflow.com/questions/66059665/how-to-combine-2-separate-formulas-based-on-additional-criteria

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

the too many arguments error is probably caused because you somehow entered 4 parameters inside an "IF" function instead of 3.

If I understand your question correctly, and need to put an extra condition in each code, try:

=IF(AND(F19="",L19>$M$18),"",IF(F19<3.5,L18*0.01,IF(F19<7.45,L18*0.006,IF(F19<11.1,L18*0.004,"0"))))

=IF(AND(F19="",L19<=$M$18),"",IF(F19<3.5,$M$18*0.01,IF(F19<7.45,$M$18*0.006,IF(F19<11.1,$M$18*0.004,"0"))))

But this seems too easy to fix, I probably misunderstood your requirements.

EDIT: OK, so you need one formula for these two

=IF(L19>$M$18, Code1, IF(L19<=$M$18, Code2, ""))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...