Skip to main content
Question

Is there a formula for counting the number of fields entered in a multi-line text box?

  • Mar 27, 2013 12:08 AM UTC
  • 0 replies
  • 278 views

I am thinking something like a "count" formula in Excel. For example, I have a field in a table which asks the user to input report names on different lines. I would then like a separate field which will count the number of reports entered.

I may be using the wrong vocabulary here, and the answer could be right under my nose, in which case I apologize for the silly question. Thanks in advance for your help.
This topic has been closed for replies.

  • Qrew Corporal
  • Mar 27, 2013 12:17 AM UTC
You can't do this with QuickBase formulas because there is no looping or counting construct.

It is simple to do with script. If your multiline text field was fid=6 and the numeric counting field was fid=7 you could use this code with the image onload technique to do the job:

$("#_fid_6").on("change",function(){ $("#_fid_7").val($(this).val().split("\n").length)});

Great, thanks for the quick answer! I will try that and let you know how it works.

Or if you have a practical limit on the number of reports they enter, you could try something like this which works for up to 10 lines (and could be expanded to more):

var Number linei = ToNumber(Trim(Part([Reports], 1,"\n"))<>"");

var Number lineii = ToNumber(Trim(Part([Reports], 2,"\n"))<>"");

var Number lineiii = ToNumber(Trim(Part([Reports], 3,"\n"))<>"");

var Number lineiv = ToNumber(Trim(Part([Reports], 4,"\n"))<>"");

var Number linev = ToNumber(Trim(Part([Reports], 5,"\n"))<>"");

var Number linevi = ToNumber(Trim(Part([Reports], 6,"\n"))<>"");

var Number linevii = ToNumber(Trim(Part([Reports], 7,"\n"))<>"");

var Number lineviii = ToNumber(Trim(Part([Reports], 8,"\n"))<>"");

var Number lineix = ToNumber(Trim(Part([Reports], 9,"\n"))<>"");

var Number linex = ToNumber(Trim(Part([Reports],10,"\n"))<>"");

$linei + $lineii + $lineiii + $lineiv + $linev + $linevi + $linevii + $lineviii + $lineix + $linex




  • Observing
  • Sep 29, 2017 3:12 AM UTC
Has there been any update that will allow the count of multiple lines in a field.