GS Conditional number format based on decimal places

21 views
Skip to first unread message

Animales Confirmation

unread,
Aug 11, 2022, 2:19:16 PM8/11/22
to Google Apps Script Community
Hello,

We use a Google Sheet for a non-profit spay and neuter clinic. We give 4 different meds based on the animal's weight.  Weight x dosage factor/pound = dosage.

Quantities are always positive. Syringes below 1cc can calculate to 2 decimal places (i.e. 0.77). Syringes above 1cc only use 1 decimal place (i.e. 1.8).

Is there a way to do a conditional format or custom # format to change the # of decimal places based whether the calculation is below or over 1. 

Or do I need to create an app script? If so, could you point me to a site that could help me get started?

Thanks, Andy
Decimal places 1 vs 2.png

Martin Molloy

unread,
Aug 11, 2022, 2:51:39 PM8/11/22
to google-apps-sc...@googlegroups.com
You could use the round (or rounddown function) in your formula

eg  =if(A1<1,round(A1,2),round(A1,1))



--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/d233e894-a078-4a50-abef-b61b74a6866an%40googlegroups.com.

Andy Mitchell

unread,
Aug 11, 2022, 3:10:36 PM8/11/22
to Google Apps Script Community
Martin, that works! Below is one of the formulas - is there an easy way to wrap the if(round) into this?  Or should I set up helper columns to do the initial dosage calcs? Thanks! Andy  
=if($B4="","",max($B4*Amino,0.1))

Reply all
Reply to author
Forward
0 new messages