Jump to content

Counting contents of fields


Recommended Posts

I have a customer that is having a dinner. I was hoping to get some help with a rule that would count the different meal choices in the different columns (one column for each guest) and return a result something like: 1 Steak, 1 Halibut

 

Sample data attached.

 

thanks

 

Aaron

Oct 12th RSVP Meal Choices by Name.xlsx.zip

Link to comment
Share on other sites

Maybe this would do the trick:

var result = [];
var meals = {};
var fields = ["Guest Entree", "2nd Guest", "3rd Guest", "4th Guest", "5th Guest", "6th Guest", "7th Guest"]
             .map(Field).filter(String).forEach(function(s){ meals[s] = meals[s] + 1 || 1 });

for (var mealChoice in meals)
 result.push((count = meals[mealChoice]) + ' ' + mealChoice + (count > 1 ? 's' : ''));

return result.join('<br/>\n');

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...