我正在使用哈里斯本尼迪克特方程来计算人们的TDEE。我正在使用Google来创建一种表单,但是使用Google有点困难。我得到一个公式解析错误。格式化是很糟糕的,很抱歉。
我知道我在某个地方犯了一个小小的逗号或括号错误,但我不知道在哪里。
该守则旨在问人们是否更喜欢公制/英制、男性/女性、身高、体重、活动水平和年龄。
这里是Google如何做if语句的。基本上是:
IF(A2 = "foo","A2 is foo")语法是:
如果(logical_expression,value_if_true,value_if_false)
=IF (D9=”Imperial”,
IF(D10=”Male”,
IF(D16=”Sedentary (no exercise)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.2,
IF(D16=”Lightly Active (1-3 days of exercise/week)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.375,
IF(D16=”Moderately Active (3-5 days of exercise/week)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.55,
IF(D16=”Very Active(6-7 days of exercise/week)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.725,
IF(D16=”Extremely Active(exercise twice a day)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.9,
“ “)))))
IF(D16=”Sedentary (no exercise)”,
655.1 + ( 4.35 x D14 ) + ( 4.7 x (D13x12+G13) ) - ( 4.7 x D12 ) x1.2,
IF(Lightly Active (1-3 days of exercise/week)”,
655.1 + ( 4.35 x D14 ) + ( 4.7 x (D13x12+G13) ) - ( 4.7 x D12 ) x1.375,
IF(Moderately Active (3-5 days of exercise/week)”,
655.1 + ( 4.35 x D14 ) + ( 4.7 x (D13x12+G13) ) - ( 4.7 x D12 ) x1.55,
IF(D16=”Very Active(6-7 days of exercise/week)”,
655.1 + ( 4.35 x D14 ) + ( 4.7 x (D13x12+G13) ) - ( 4.7 x D12 ) x1.725,
IF(D16=”Extremely Active(exercise twice a day)”,
655.1 + ( 4.35 x D14 ) + ( 4.7 x (D13x12+G13) ) - ( 4.7 x D12 ) x1.9,
“ “))))))
IF(D10=”Male”,
IF(D16=”Sedentary (no exercise)”,
66.5 + ( 13.75 x D14 ) + ( 5.003 x D13 ) – ( 6.755 x D12 )x1.2,
IF(Lightly Active (1-3 days of exercise/week)”,
66.5 + ( 13.75 x D14 ) + ( 5.003 x D13 ) – ( 6.755 x D12 )x1.375,
IF(Moderately Active (3-5 days of exercise/week)”,
66.5 + ( 13.75 x D14 ) + ( 5.003 x D13 ) – ( 6.755 x D12 )x1.55,
IF(D16=”Very Active(6-7 days of exercise/week)”
66.5 + ( 13.75 x D14 ) + ( 5.003 x D13 ) – ( 6.755 x D12 )x1.725,
IF(D16=”Extremely Active(exercise twice a day)”,
66.5 + ( 13.75 x D14 ) + ( 5.003 x D13 ) – ( 6.755 x D12 )x1.9,
“ “)))))
IF(D16=”Sedentary (no exercise)”,
655.1 + ( 9.563 x D14 ) + ( 1.850 x D13 ) – ( 4.676 x D12 ) x1.2,
IF(Lightly Active (1-3 days of exercise/week)”,
655.1 + ( 9.563 x D14 ) + ( 1.850 x D13 ) – ( 4.676 x D12 ) x1.375,
IF(Moderately Active (3-5 days of exercise/week)”,
655.1 + ( 9.563 x D14 ) + ( 1.850 x D13 ) – ( 4.676 x D12 ) x1.55,
IF(D16=”Very Active(6-7 days of exercise/week)”,
655.1 + ( 9.563 x D14 ) + ( 1.850 x D13 ) – ( 4.676 x D12 ) x1.725,
IF(D16=”Extremely Active(exercise twice a day)”,
655.1 + ( 9.563 x D14 ) + ( 1.850 x D13 ) – ( 4.676 x D12 ) x1.9,
“ “))))))
)发布于 2016-07-02 15:01:23
像IF(Lightly Active (1-3 days of exercise/week)”这样的东西显然是行不通的。这种嵌套的IFs不应该在第一,它是一个雷区的打字。使用hlookup或vlookup代替。vlookup替换五个嵌套IFs的示例:
=if(D9=”Imperial”,
if(D10=”Male”,
vlookup(D16, {
”Sedentary (no exercise)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.2;
”Lightly Active (1-3 days of exercise/week)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.375;
”Moderately Active (3-5 days of exercise/week)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.55;
”Very Active(6-7 days of exercise/week)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.725;
”Extremely Active(exercise twice a day)”,
66 + ( 6.2 x D14 ) + ( 12.7 x (D13x12+G13) ) – ( 6.76 x D12 )x1.9,
}, 2, false)
....请注意,您可以在这里放置15而不是5个选项,并且不需要新的括号。
根据数据的结构方式,您可以将这个参考表放在工作表的其他地方,例如表!A1:b5、Table!A6:B11等等:
=if(D9=”Imperial”,
if(D10=”Male”,
vlookup(D16, Table!A1:B5, 2, false),
vlookup(D16, Table!A6:B11, 2, false)
),
if(D10=”Male”,
vlookup(D16, Table!A12:B16, 2, false),
vlookup(D16, Table!A17:B21, 2, false)
)
)可以将每个vlookup封装在iferror中,这样当输入数据不是预期的类型时,就可以得到空白输出,而不是#N/A!错误(尽管后者提供了更多信息)。
https://stackoverflow.com/questions/38158649
复制相似问题