简体   繁体   English

谷歌表格嵌套如果公式,两位数和三位数不同?

[英]Google sheets nested if formula, different for two digits and three digits?

I have a formula in google sheets that is我在谷歌表格中有一个公式是

=IF(H7<-3,0.95*F7,IF(H7<3,F7,F7*1.01))

This should only be if F7 is three digits and more.仅当 F7 为三位数及以上时才应如此。 I'd like to add a condition further that if F7 is two digits or less (under 100) then it should be我想进一步添加一个条件,如果 F7 是两位数或更少(低于 100),那么它应该是

=IF(H7<-3,0.9*F7,IF(H7<3,F7,F7*.95))

How to combine both of this?如何将这两者结合起来?

To calculate the digits of a number you can actually calculate the length of the number.要计算数字的位数,您实际上可以计算数字的长度。 However, there are three possible scenarios based on what you want to achieve and what is your input;但是,根据您想要实现的目标和您的输入,有三种可能的情况; float number or integer:浮点数或 integer:


If you want to calculate the number of digits of a float number after the decimal point (seperated by ".") use that:如果要计算小数点后浮点数的位数(用“.”分隔),请使用:

=if(LEN(RIGHT(F7,LEN(F7)-FIND(".",F7))) >2,IF(H7<-3,0.95*F7,IF(H7<3,F7,F7*1.01)),IF(H7<-3,0.9*F7,IF(H7<3,F7,F7*.95)))

If you want to calculate the total number of digits of a float number before and after the decimal point (seperated by ".") use that:如果要计算小数点前后浮点数的总位数(用“.”分隔),请使用:

 =if(len(F7)-1>2,IF(H7<-3,0.95*F7,IF(H7<3,F7,F7*1.01)),IF(H7<-3,0.9*F7,IF(H7<3,F7,F7*.95)))

If you want to calculate the total number of digits of an integer then use:如果要计算integer的总位数,请使用:

=if(len(F7)>2,IF(H7<-3,0.95*F7,IF(H7<3,F7,F7*1.01)),IF(H7<-3,0.9*F7,IF(H7<3,F7,F7*.95)))

Based on your question I assume you need the last scenario, so pick up yourself whatever it suits you the best.根据您的问题,我假设您需要最后一种情况,因此请选择最适合您的方式。

try:尝试:

=IF(LEN(F7*1)<3, 
 IF(H7 < -3, 0.9*F7,  IF(H7 < 3,F7, F7*.95)), 
 IF(H7 < -3, 0.95*F7, IF(H7 < 3,F7, F7*1.01)))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM