Skip to main content

I have an org chart with a field for salary. I'd like to write a formula that sums the salaries of subordinates under each manager. To do this I attempted making a custom data field "Salary" in each employee's shape and a custom field "Department Salary" in the manager's shape. In "Department Salary" this is the formula that I tried:
=SUM(DESCENDANTS(@"Salary"))



Seems logical right? But I get the result of 0.



Why is this happening?



Thanks in advance for any help!

Update: I have tried using salary as a label as well as a custom data field. Same result.


Hi Andrew 

Thank you for posting in the community! As a first step would you mind reviewing our formulas documentation if you haven't already? If every employee shape on the page has a field titled "Salary" - you can calculate the sum of the salary values (for shapes under a manager) by creating a new field in your page data called 'Total Salary'. Entering =SUM(DESCENDANTS."Salary") as the value of this field should calculate the sum of all the values in 'Salary' for every shape under a manager.

Let me know if you have trouble with this.


Thank you. For some reason that works in a page data custom field for the whole page. But it's still returning 0 for a custom field in a manager's block for only that manager's descendants.


Thanks for following up on this Andrew. Using the downstream formula may be the solution here; please see this Lucid article for details on this formula.  If that does not work please submit a support ticket here so that I can look at your chart and better identify which formula is best for your specific use case. 


Thanks for your patience on this - and for posting in the community!


Thank you! Using the downstream and downstreamdeep formulas did the trick.


While I'm here what is the difference between using periods and using parentheses in formulas? A period only gives me the correct answer in my case. But when I start typing a formula and hit Tab to use the autofill suggestion Lucid puts parentheses. For example:
=SUM(DOWNSTREAMDEEP."Salary") --> 15000 (the correct answer in my case)
=SUM(DOWNSTREAMDEEP("Salary")) --> 11
=SUM(DOWNSTREAMDEEP(@"Salary")) --> 0


If Lucid wants me to use the autofill why does the answer come out wrong? What's the difference?


Hi Andrew 


I am so glad to hear that this formula worked for you! The difference is that one hits every downstream object (and pulls the salary from it) and the other finds singular salary objects downstream and adds them together.


For your first example you are using downstreamdeep as an array that contains multiple objects and it's summing all of the salary objects in that array. In your second example you are calling a single salary object (and no others) so it is just summing that singular salary. In your last example you are calling all of the salary objects to sum them -  but it may not be called correctly because of the way you set up your data (as the response should not be zero). 


Thanks again for posting in the community! I am sure this specific example will be very helpful for others using formulas. 


Hi! I’m Micah from Lucid’s community team. 👋 Jumping in here to share about Lucid’s Data Trusted User Group. This group is made up of knowledgeable users who regularly analyze and visualize data in their work. As part of this group, you’ll have the opportunity to connect directly with Lucid’s product team, gain early access to beta features, and share insights about your needs, shaping the future of Lucid’s data solutions 🎉 You can learn more and request to join here. Thanks!

 


Reply