# Formula to calculate only if a cell has value, else to be blank

**URL:** <https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299>\
**Category:** Ask for Help\
**Created:** [March 9, 2020, 5:12am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299 "2020-03-09T05:12:51Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)\
**Post date:** [March 9, 2020, 5:12am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/1 "2020-03-09T05:12:51Z")

</div>

I am trying to create a quiz, and in the sheet, I have three columns, one for Answer, one for Correct Answer, and one for Result.  
Initially, the Answer column will be blank, as user has not selected an answer, the Correct answer will have the correct answer value, and the Result column will show True if Answer = Correct Answer and false if Answer not equal to Correct Answer. But, when the answer Column is blank, I want the Result to be blank, Right now, with the formula I have used =ARRAYFORMULA(IF(LEN(A2:A)=0,“”,G2:G=H2:H), it is showing FALSE. Could you help me with the correct formula I can use to keep Result blank if the Answer is blank?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/1/10eb823b3b52a35c741985a688be13633db31025.png)

---

<div class="post-metadata">

**Author:** ![Christophe\_HK](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/christophe_hk/32/4161_2.png) [@Christophe\_HK](https://community.glideapps.com/u/Christophe_HK)\
**Post date:** [March 9, 2020, 6:10am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/2 "2020-03-09T06:10:22Z")

</div>

Use a template column in Glide data editor to set the response (or use a gsheet column, no matter).

Then add an if/then/else column in data editor with the following : if response is empty then empty else “answer column”.

And in your app, the answer will be displayed using the if/then/else column.

---

<div class="post-metadata">

**Author:** ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)\
**Post date:** [March 9, 2020, 6:36am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/3 "2020-03-09T06:36:16Z")

</div>

I am sorry I am not able to understand your approach. If I use the IF-THEN-ELSE column in data editor, is this what I use?  
If Answer is empty, then Result is Empty  
Else Result = Answer?

Is that what you are suggesting?

---

<div class="post-metadata">

**Author:** ![Christophe\_HK](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/christophe_hk/32/4161_2.png) [@Christophe\_HK](https://community.glideapps.com/u/Christophe_HK)\
**Post date:** [March 9, 2020, 6:41am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/4 "2020-03-09T06:41:53Z")

</div>

The if/then/else column will be populated as follow : if answer is empty then “empty” (null value) else “value of the result column” (true or false)

And your result column will also be an if/then/else column : if answer is empty then empty And if answer equals correct answer then TRUE else FALSE

---

<div class="post-metadata">

**Author:** ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)\
**Post date:** [March 9, 2020, 6:49am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/5 "2020-03-09T06:49:33Z")

</div>

How do i check if Answer equals Correct Answer using the If-Then-Else column. Because, I dont see an option to compare two columns, it only compares a column with a value we need to enter.  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/2X/6/69e89cef2b4d3300357eaf035daaea11f4012a12.png)

---

<div class="post-metadata">

**Author:** ![Manan\_Mehta](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/manan_mehta/32/13957_2.png) [@Manan\_Mehta](https://community.glideapps.com/u/Manan_Mehta)\
**Post date:** [March 9, 2020, 7:03am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/6 "2020-03-09T07:03:33Z")

</div>

Try this formula instead  
=arrayformula(IF(LEN(G2:G)=0,"",if(G2:G=H2:H,TRUE,FALSE)))

---

<div class="post-metadata">

**Author:** ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)\
**Post date:** [March 9, 2020, 7:06am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/7 "2020-03-09T07:06:55Z")

</div>

> [@Manan\_Mehta](#):
>
> =arrayformula(IF(LEN(G2:G)=0,“”,if(G2:G=H2:H,TRUE,FALSE)))

That worked! Thank you very much! 😍

---

<div class="post-metadata">

**Author:** ![Ralf](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/ralf/32/492_2.png) [@Ralf](https://community.glideapps.com/u/Ralf)\
**Post date:** [March 9, 2020, 7:18am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/8 "2020-03-09T07:18:58Z")

</div>

Try this nested formula in Sheets:

IF(IF(len(A2:A)=0,"",G2:G=H2:H)=FALSE,"",IF(len(A2:A)=0,"",G2:G=H2:H))

---

<div class="post-metadata">

**Author:** ![vijay](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/vijay/32/3259_2.png) [@vijay](https://community.glideapps.com/u/vijay)\
**Post date:** [March 9, 2020, 7:21am UTC](https://community.glideapps.com/t/formula-to-calculate-only-if-a-cell-has-value-else-to-be-blank/5299/9 "2020-03-09T07:21:23Z")

</div>

Thanks for helping. I already got the answer.as mentioned above.
