Formulas and Functions

Formulas and Functions

Ask for help with your formula and find examples of how others use formulas and functions to solve a similar problem.

Sum of Children While Maintaining Column Formula

✭✭✭✭
edited 05/15/24 in Formulas and Functions

It would be incredibly helpful to allow for the sum of the children on a parent row, but maintain the column formula.

Best Answer

  • Employee
    Answer βœ“

    Hi @Yvette Moreland

    Thank you for outlining your sheet! I definitely believe this is possible to do for your scenario.

    We can first check how many children a current row has. If the current row has 0 children, it is a child row itself and you do your multiplication formula. However if there is at least 1 child row beneath the current row, you want the formula to SUM the child values.

    Try something like this:

    =IF(COUNT(CHILDREN([Primary Column]@row)) = 0, ([HOTEL NIGHTLY RATE]@row * [NUMBER OF NIGHTS]@row), SUM(CHILDREN()))

    Note that you'll need to change out the [Primary Column] name to your column name. Does that make sense?

    Cheers,

    Genevieve

    Need more information? πŸ‘€ | Help and Learning Center

    こんにけは (Konnichiwa), Hallo, Hola, Bonjour, OlΓ‘, Ciao!πŸ‘‹ | Global Discussions

Answers

  • Hi @Yvette Moreland

    We may be able to build this into your formula! Can you clarify what formula you're using in the child rows?

    Need more information? πŸ‘€ | Help and Learning Center

    こんにけは (Konnichiwa), Hallo, Hola, Bonjour, OlΓ‘, Ciao!πŸ‘‹ | Global Discussions

  • ✭✭✭✭

    I have columns for travel expenses and some of the columns are formulas. The rows are the names and dates of the travelers. One example: HOTEL NIGHTLY RATE and NUMBER OF NIGHTS are columns and the TOTAL HOTEL COSTS column is a formula multiplying those two. I need totals by column, so I have the travelers as child rows so the parent row will give me the totals. The challenge is when someone inserts a new row, (rather than copying a blank row) they lose the formulas. I would like to have the column formulas, but keep the parent row as the totals. I haven't found a workaround. This is a template used to make hundreds of versions for our different locations, and many users are beginning Smartsheet users. I am trying to make it more user friendly.

  • Employee
    Answer βœ“

    Hi @Yvette Moreland

    Thank you for outlining your sheet! I definitely believe this is possible to do for your scenario.

    We can first check how many children a current row has. If the current row has 0 children, it is a child row itself and you do your multiplication formula. However if there is at least 1 child row beneath the current row, you want the formula to SUM the child values.

    Try something like this:

    =IF(COUNT(CHILDREN([Primary Column]@row)) = 0, ([HOTEL NIGHTLY RATE]@row * [NUMBER OF NIGHTS]@row), SUM(CHILDREN()))

    Note that you'll need to change out the [Primary Column] name to your column name. Does that make sense?

    Cheers,

    Genevieve

    Need more information? πŸ‘€ | Help and Learning Center

    こんにけは (Konnichiwa), Hallo, Hola, Bonjour, OlΓ‘, Ciao!πŸ‘‹ | Global Discussions

  • ✭✭✭✭

    Hi Genevieve,

    Thank you for the response. Unfortunately, I am not getting it to work.

    your formula: =IF(COUNT(CHILDREN([Primary Column]@row)) = 0, ([HOTEL NIGHTLY RATE]@row * [NUMBER OF NIGHTS]@row), SUM(CHILDREN()))

    calculates the child rows, but when I change it a column formula, it does not sum the parent row.

    I tried other columns, and I have the same issue when I made the formula a column formula. (FYI, my Primary Column is titled ".")

    # of nights column:

    =IF(COUNT(CHILDREN([.]@row)) = 0, ([Departure Date]@row - [Arrival Date]@row), SUM(CHILDREN()))

    This returns blank on parent row

    Mileage Costs (2024 rate $0.67) column:

    =IF(COUNT(CHILDREN([.]@row)) = 0, ([If Driving - Miles (from home location)]@row * 0.67) * 2, SUM(CHILDREN()))

    This returns $0 on the parent row.

  • Hi @Yvette Moreland

    The reason you're seeing 0 in the top parent row is because the Primary column you're referencing has "no children" because the cells below it are blank.

    Try referencing a column that will always have text in it, perhaps the Name column?

    =IF(COUNT(CHILDREN(Name@row)) = 0, ([HOTEL NIGHTLY RATE]@row * [NUMBER OF NIGHTS]@row), SUM(CHILDREN()))

    Need more information? πŸ‘€ | Help and Learning Center

    こんにけは (Konnichiwa), Hallo, Hola, Bonjour, OlΓ‘, Ciao!πŸ‘‹ | Global Discussions

  • ✭✭✭✭

    Of course! That is it. Thank you so much for your help.

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!

Trending in Formulas and Functions

  • I'm trying to create a SUMIF formula that looks at the salesperson name in a column and adds up or totals their $ sales in another column. To ultimately show in Dashboard of Totals Sales by Salesperso…
    User: "Allan Z"
    Answered βœ“
    9
    2
  • Good day Smartsheet Team, Getting an unparseable error on this formula: =IF($Name@row <> "",(SUMIFS({Expense}, {Period},1, {Type}, OR(@cell = "RES602782", @cell = "RES602497")),"") Trying to pull in a…
    User: "stratman"
    Answered βœ“
    15
    2
  • I have a sheet that compiles all the responses from a form. The sheet has multiple start and end date columns, but only one start and one end date cell is NOT blank depending on the activity selected …
    User: "m_anderson"
    Answered βœ“
    13
    2