如何在Excel中进行多级别查询?

我试图做一个多级别,如果其他查询在Excel中,它将检查多个variables,如果它属于其中一个类别,那么它会 – 一个百分比,如果它不落入任何类别,然后它会说“不适用”

伪代码看起来像这样:

If $income <90,000 and $age is <65 then - 27.82%, else if $income range(90,000 - 105,000) and $age <65 then $premium - 18.55%, else if $income range(105,001 - 140,000) and $age <65 then $premium - 9.27%, else if $income >140,000 and $age <65 then - 0%, else if $income <90,000 and $age range(65-69) then $premium - 32.46%, else if $income range(90,000 - 105,000) and $age range(65-69) then $premium - 23.18%, else if $income range(105,001 - 140,000) and $age range(65-69) then $premium - 13.91%, else if $income >140,000 and $age range(65-69) then $premium - 0%, else if $income <90,000 and $age <70 then - 37.09%, else if $income range(90,000 - 105,000) and $age <70 then $premium - 27.82%, else if $income range(105,001 - 140,000) and $age <70 then $premium - 18.55%, else if $income >140,000 and $age <70 then $premium - 0%, else "NA"; $income = cell j4 $age = cell i4 $premium = cell q4 

我可以做一个单一级别的查询,看起来像这样:

 =IF(AND(I5>64,I5<69,J5>90000,J5<105001),800*$Y$5,"NA") 

但我不知道如何在Excel中做多个if else语句来捕获所有可能的类别,或者如果有更好的方法。

我会先把各种if语句分成几个年龄段,然后再做每个年龄段的收入报表。

像这样的东西:

 =IF(I4<65, IF(J4<90000,27.82,IF(J4<=105000,18.55,IF(J4<=140000,9.27,0))), IF(I4<=69, IF(J4<90000,32.46,IF(J4<=105000,23.18,IF(J4<=140000,13.91,0))), IF(J4<90000,37.09,IF(J4<=105000,27.82,IF(J4<=140000,18.55,0))))) 

这是一个带有注释的版本( 不要实际粘贴到Excel中 ):

 =IF(I4<65, // if the age is less than 65 IF(J4<90000,27.82,IF(J4<=105000,18.55,IF(J4<=140000,9.27,0))), // else if the age is less than or equal to 69 IF(I4<=69, IF(J4<90000,32.46,IF(J4<=105000,23.18,IF(J4<=140000,13.91,0))), // else (the age must be 70 or greater so need to specify this) IF(J4<90000,37.09,IF(J4<=105000,27.82,IF(J4<=140000,18.55,0))))) 

嵌套的IF语句:

 IF( condition1, value_if_true1, IF( condition2, value_if_true2, value_if_false2 )) 

IF-ELSE陈述:

 IF condition1 THEN value_if_true1 ELSEIF condition2 THEN value_if_true2 ELSE value_if_false2 END IF