Writing a Formula

%3CLINGO-SUB%20id%3D%22lingo-sub-2074133%22%20slang%3D%22en-US%22%3EWriting%20a%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2074133%22%20slang%3D%22en-US%22%3E%3CP%3EI'm%20trying%20to%20write%20an%20IF..AND%20statement%20that%20will%20return%20%2237%22%20if%20A2%20is%20%22Regular%22%20and%20C2%20is%20%221%22%20and%20will%20return%20%2241%22%20is%20A2%20is%20%22Regular%22%20and%20C2%20is%20%222%20and%20will%20return%20%2240%22%20if%20A2%20is%20%22Honors%22%20and%20C2%20is%20%221%22%20and%20will%20return%20%2248%22%20if%20A2%20is%20%22Honors%22%20and%20C2%20is%20%222.%22%20What%20I%20have%20so%20far%20is%20%22%3DIF((AND(A2%3D%E2%80%9DRegular%E2%80%9D)%2C(C2%3D1))%2C37%2CIF(AND(A2%3D%E2%80%9DRegular%E2%80%9D)%2C(C2%3D2))%2C41%2CIF(AND(A2%3D%E2%80%9DHonors%E2%80%9D)%2C(C2%3D1))%2C40%2CIF(AND(A2%3D%E2%80%9DHonors)%2C(C2%3D2))%2C48)%22%26nbsp%3B%20I'm%20hoping%20the%20problem%20is%20just%20the%20parentheses%20but%20so%20far%20this%20formula%20doesn't%20work.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2074133%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2074307%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20a%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2074307%22%20slang%3D%22en-US%22%3E%3DIF(%3CBR%20%2F%3EAND(A2%3D%E2%80%9DRegular%E2%80%9D%2CC2%3D1)%2C37%2C%3CBR%20%2F%3EIF(%3CBR%20%2F%3EAND(A2%3D%E2%80%9DRegular%E2%80%9DC2%3D2)%2C41%2C%3CBR%20%2F%3EIF(%3CBR%20%2F%3EAND(A2%3D%E2%80%9DHonors%E2%80%9D%2CC2%3D1)%2C40%2C%3CBR%20%2F%3EIF(%3CBR%20%2F%3EAND(A2%3D%E2%80%9DHonors%2CC2%3D2)%2C48%2C%3CBR%20%2F%3E%E2%80%9CNo%20Result%E2%80%9D%3CBR%20%2F%3E)%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2074309%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20a%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2074309%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F932976%22%20target%3D%22_blank%22%3E%40rbronson%3C%2FA%3E%26nbsp%3Byou%20have%20some%20problems%20with%20()%20and%20%22%22%20and%20I%20added%20a%20%22n%2Fa%22%20just%20in%20case.%26nbsp%3B%20try%20this%3A%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(AND(A2%3D%22Regular%22%2CC2%3D1)%2C37%2CIF(AND(A2%3D%22Regular%22%2CC2%3D2)%2C41%2CIF(AND(A2%3D%22Honors%22%2CC2%3D1)%2C40%2CIF(AND(A2%3D%22Honors%22%2CC2%3D2)%2C48%2C%22n%2Fa%22))))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3ENote%20you%20could%20also%20use%20the%20IFS()%20statement%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIFS(AND(A2%3D%22Regular%22%2CC2%3D1)%2C37%2CAND(A2%3D%22Regular%22%2CC2%3D2)%2C41%2CAND(A2%3D%22Honors%22%2CC2%3D1)%2C40%2CAND(A2%3D%22Honors%22%2CC2%3D2)%2C48)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3Eand%20IF%20the%20only%20options%20for%20A2%20are%20Regular%20or%20Honors%20and%20for%20C2%20are%201%20or%202%20then%20you%20could%20make%20it%20shorter%20but%20it%20may%20be%20less%20easy%20to%20read%3A%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3DIF(A2%3D%22Regular%22%2C37%2B(C2%3D2)*4%2C40%2B(C2%3D2)*8)%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2076444%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20a%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2076444%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%20%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F9832%22%20target%3D%22_blank%22%3E%40Wyn%20Hopkins%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2076445%22%20slang%3D%22en-US%22%3ERe%3A%20Writing%20a%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2076445%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F570951%22%20target%3D%22_blank%22%3E%40mtarler%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

I'm trying to write an IF..AND statement that will return "37" if A2 is "Regular" and C2 is "1" and will return "41" is A2 is "Regular" and C2 is "2 and will return "40" if A2 is "Honors" and C2 is "1" and will return "48" if A2 is "Honors" and C2 is "2." What I have so far is "=IF((AND(A2=”Regular”),(C2=1)),37,IF(AND(A2=”Regular”),(C2=2)),41,IF(AND(A2=”Honors”),(C2=1)),40,IF(AND(A2=”Honors),(C2=2)),48)"  I'm hoping the problem is just the parentheses but so far this formula doesn't work. 

6 Replies
=IF(
AND(A2=”Regular”,C2=1),37,
IF(
AND(A2=”Regular”C2=2),41,
IF(
AND(A2=”Honors”,C2=1),40,
IF(
AND(A2=”Honors,C2=2),48,
“No Result”
)

@rbronson you have some problems with () and "" and I added a "n/a" just in case.  try this:

=IF(AND(A2="Regular",C2=1),37,IF(AND(A2="Regular",C2=2),41,IF(AND(A2="Honors",C2=1),40,IF(AND(A2="Honors",C2=2),48,"n/a"))))

Note you could also use the IFS() statement:

 

=IFS(AND(A2="Regular",C2=1),37,AND(A2="Regular",C2=2),41,AND(A2="Honors",C2=1),40,AND(A2="Honors",C2=2),48)

and IF the only options for A2 are Regular or Honors and for C2 are 1 or 2 then you could make it shorter but it may be less easy to read:

 

=IF(A2="Regular",37+(C2=2)*4,40+(C2=2)*8)

 

 

 

 

 

 

Thanks @Wyn Hopkins 

Thanks @mtarler 

@rbronson 

One more variant

=MMULT(MMULT(--(A2={"Regular","Honors"}),{37,41;40,48}),--(C2={1;2}))

Hi 

 

A cleaner way of doing this would be to have a small reference table and use a SUMIFS

 

image.png