2016-07-02 2 views
0

사람들의 TDEE를 계산할 때 Harris Benedict Equation을 사용하고 있습니다. Google 시트를 사용하여 일종의 양식을 만들었지 만 Google 시트는 일하기가 어렵습니다. 수식 구문 분석 오류가 나타납니다. 포맷은 매우 유감스러운 일입니다.다중 중첩 된 IF 문을 사용하여 피트니스 계산기 디버깅

나는 작은 쉼표 또는 괄호 오류를 어딘가에서 만들고 있음을 알고 있지만 어디 있는지 모르겠습니다.

코드는 사람들이 미터법/영국식, 남성/여성, 키, 몸무게, 활동 수준 및 나이를 선호하는지 묻는 것으로되어 있습니다.

다음은 Google 시트가 수행하는 방법입니다. if statements. 그것은

은 - 거의 IF (A2 = "foo", "A2가 foo는") (논리 _ 표현식, TRUE 인 _ 경우 _ 값, 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, 

              “ “)))))) 

    ) 

답변

2

당신은이 경우

구문

입니다 분명히 작동하지 않을 것 인 IF(Lightly Active (1-3 days of exercise/week)”와 같은 물건. IF의 이러한 종류의 중첩은 처음에는 존재해서는 안되며 오타의 지뢰밭입니다. 대신 hlookup 또는 vlookup을 사용하십시오. vlookup 교체 다섯 중첩 된 IF를 예 :

=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, 표 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) 
    ) 
    ) 

하나 각각 vlookupiferror에 감쌀 수 있으므로 입력 데이터가 예상 종류가 아닌 경우 # N/A 대신 빈 출력이 표시됩니다! 오류 (후자는 더 유익 함).

관련 문제