Need an Formula to generate Categories column

We are looking for the Categories to auto generate from the sub-categories multi dropdown selection. We were achieved this by using the =IF(COUNTIF([Sub-Categories]@row, CONTAINS("Fruits", @cell)) >= 1, "Fruits") + CHAR(10) + IF(COUNTIF([Sub-Categories]@row, CONTAINS("Meats", @cell)) >= 1, "Meats") + CHAR(10) + IF(COUNTIF([Sub-Categories]@row, CONTAINS("Vegetables", @cell)) >= 1, "Vegetables") but it is not dynamic, we should not define the search text here like "Fruits". We are looking extract first text of each dropdown selection (Non-duplicate) -> (i.e., Fruits/Meats/Vegetables) - under categories. Could you please help me out here?



  • Kelly P.
    Kelly P. ✭✭✭✭✭✭
    edited 07/26/23

    @Gaja Rm

    This type of approach allows for flexibility of categories; however, it would need modification for the multi-select aspect. Will revisit as able later today....

    =IFERROR(LEFT([Sub-Categories]@row, FIND("-", [Sub-Categories]@row) - 1), "")

    Hope this helps!

  • Gaja Rm
    Gaja Rm ✭✭✭

    @Kelly P. Thanks for the quick response, your formula works only for the first selection, I need to extract all First words from each selection.

  • Paul Newcome
    Paul Newcome ✭✭✭✭✭✭

    I would suggest creating a table that has all subcategories in one column and the corresponding category in another. Then you can use a JOIN/COLLECT combo to pull in the appropriate categories. The table can be on a separate sheet and the formula would have cross sheet references for ranges, but here's a quick example.

    =JOIN(DISTINCT(COLLECT([Category (Table)]:[Category (Table)], [Subcategory (Table)]:[Subcategory (Table)], HAS([Sub-categories]@row, @cell))), CHAR(10))

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!