Count # of related items in calculation field
I have an app that contains companies and an app that contains clients. Clients reference companies. I'd like to add a calculation field in the companies' app that counts the number of referenced clients. Any ideas on how to get this done? Thanks a lot for your help!
-
I've tried three different ways and all return "0". I have an App called Campaign and an App called Leads - each lead is related to a campaign. The Leads App is in a different workspace than the Campaign App. This is on a campaign item that shows 151 leads as related items. Lead Name is a text field.
Method 1;
@All of Lead Name.length;
Method 2;
var leads = @All of Lead Name;
leads.length;Method 3;
var leads = @All of Lead Name.join();
leads.length; -
Hi Joshua,
is it possible that you have one relation from Campaign to Leads (= OUTGOING if you are in the Campaign App) and another relation from Leads to Campaign (=INCOMING)?
If so, you've selected the wrong token (variable) from the list which opens after entering @ . Try this: Enter only @Name (or @all of lead name) and look if there are 2 tokens "All of Lead Name".
Btw: Method 3 would count the number of the length of the string (number of characters) which was created by .join()Rainer
-
Hi Rainer,
Your response has helped me identify what the problem is. There isn't an outgoing connection, however there are 5 possible @All of Lead Name selections because the Leads App is part of an App Package that I've created to use in a separate workspace for each Campaign (and used 5 times in 5 separate workspaces so far). The Campaigns App is like the mother ship pulling in stats from the Leads Apps in the workspaces for each campaign.
Does this mean... I have to redo the calc field individually for each new campaign item to connect it to the correct corresponding "spawn" of the Leads App?
And if so, I'll have to figure out how the heck to identify the right one to connect to. -
Hi Joshua,
for figuring out the right "Lead" you can temporarily rename the Lead-fields (Lead Name 1, Lead Name 2 ... ). Then in the calculation fields write after
@all of lead name 1 // from App Leads in Workspace X
Everthing behind // doesn't influence the calculation , it's used for comments/notes.After you've done that you can rename the field to it's original name.
If one campaign is referenced only by one of the five Lead-Apps, there's no need for 5 calculation fields. It depends on what you want to display in this calculation field how the code has to look like to show only the result from the right app.
If you can describe some more details, maybe I have a tip.Rainer
-
I am desperate and hope somebody can help me...
I simply want a calculation for a calendar event that displays the number of attending people.The recommendation I received from the Podio Support is to use
var items = @Item
@Item.lengthThis works of course, but it's displaying anybody (total number of) who got invited to an event. Having read the posts in this topic I was hoping to be able to use something like
var items = @ItemOFaccepted
@Item.lengthBut this returns a script reference error "field_tokenOFaccepted is not defined"
Can I make this work at all? How?
-
--SOLVED--
I found this https://help.podio.com/hc/en-us/community/posts/201849698-Counting-number-of-related-apps and understood the "any field in the relation" and the ".length" elements.
my calculation now is "@All of Region Specific - Unique ID.length"
-------------------
Hi,
Is there a simple way to fill a field with the number of related items ?
Thank you.
Please sign in to leave a comment.
Comments
14 comments