[Solved] Performing calculation based on Checkbox condition

Discuss the spreadsheet application
Post Reply
BigDon
Posts: 4
Joined: Mon Aug 22, 2016 5:41 pm

[Solved] Performing calculation based on Checkbox condition

Post by BigDon »

I want to perform a calculation based on the condition (checked or not checked) of a checkbox.

The calculation I want to perform is this: If checkbox A1 is checked, take the value on sheet 2 cell G17 and multiply it by 4. Otherwise return 0. I have tried this

Code: Select all

=IF(A1=TRUE;(Inventory.G17*4);0)
This only returns the TRUE or FALSE state of the checkbox. I have also tried to test for the value in another cell assigning that cell the value of the condition of the checkbox (TRUE/FALSE or 0/1). I get the value of that cell returned to my function performing calculation cell.

My brain tells me this is easy --- my fingers aren't typing out the correct function!!!

Is this possible without a LOT of programming macros? I have several lines that I want to perform similar calculations on based on different cell values on another page.

Thanks for your help!
Last edited by BigDon on Mon Aug 22, 2016 8:54 pm, edited 1 time in total.
-DON-
OpenOffice 4.1.2 on Windows 7 Ultimate
FJCC
Moderator
Posts: 9279
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Performing a calculation based on Checkbox condition

Post by FJCC »

A version of your formula works for me. See the attached file. Simply using IF(A1;Inventory.G17*4;0) should also work.
Attachments
CheckBox.ods
(9.96 KiB) Downloaded 416 times
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
User avatar
floris v
Volunteer
Posts: 4431
Joined: Wed Nov 28, 2007 1:21 pm
Location: Netherlands

Re: Performing a calculation based on Checkbox condition

Post by floris v »

Toggle Design mode to ON. Right click the check box, select Control, click the Data tab (in the middle of the dialog box).
Set Linked Cell to A1; set Reference value for On and Off (at the bottom), they're always strings, so enter A and B, for example.
Modify your formula to

Code: Select all

=IF(A1="A";(Inventory.G17*4);0)
OpenOffice 4.1.11 on Ubuntu; LibreOffice 6.4 on Linux Mint, LibreOffice 7.6.2.1 on Ubuntu
If your problem has been solved or your question has been answered, please edit the first post in this thread and add [Solved] to the title bar.
Nederlandstalig forum
BigDon
Posts: 4
Joined: Mon Aug 22, 2016 5:41 pm

Re: Performing a calculation based on Checkbox condition

Post by BigDon »

Thanks for all your replys!!! About the time I had began receiving your responses my fingers decided to cooperate :lol: ... and my brain began working too!! I had turned one of the cells I was working on into a "boolean" cell and THAT was throwing the "TRUE/FALSE" value that was confusing. So after fixing that little issue, I plugged back in my original formula and IT WORKED!!

Thanks for all of you taking your time to respond to this. I feel REALLY stupid now!! :oops: :oops: :oops:
-DON-
OpenOffice 4.1.2 on Windows 7 Ultimate
Post Reply