Forum Discussion
Separate Results of Calculated Column with Commas
- Oct 05, 2023
HodgePodge47 Try using calculated formula like this:
=TRIM(IF([PROD-1]>0,"PROD1 ","")&IF([PROD-2]>0,"PROD2 ","")&IF([PROD-3]>0,"PROD3 ","")&IF([PROD-4]>0,"PROD4 ","")&IF([PROD-5]>0,"PROD5",""))
Then apply JSON column formatting with:
{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=replaceAll(@currentField, ' ', ', ')" }
Reference: SharePoint: Replace All Occurrences of Substring in a String using JSON Formatting
You can also use internal column name instead of @currentField in JSON. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
HodgePodge47 Try using calculated formula like this:
=TRIM(IF([PROD-1]>0,"PROD1 ","")&IF([PROD-2]>0,"PROD2 ","")&IF([PROD-3]>0,"PROD3 ","")&IF([PROD-4]>0,"PROD4 ","")&IF([PROD-5]>0,"PROD5",""))
Then apply JSON column formatting with:
{
"$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
"elmType": "div",
"txtContent": "=replaceAll(@currentField, ' ', ', ')"
}
Reference: SharePoint: Replace All Occurrences of Substring in a String using JSON Formatting
You can also use internal column name instead of @currentField in JSON. You can get the internal name of your SharePoint list columns by following this article: How to find the Internal name of columns in SharePoint Online?
Please click Mark as Best Response & Like if my post helped you to solve your issue. This will help others to find the correct solution easily. It also closes the item. If the post was useful in other ways, please consider giving it Like.
ganeshsanap, you are a SUPERSTAR!
Thanks so much! That workaround worked beautifully. I'd looked at replaceAll previously, but couldn't figure out a way to make it work without appending a comma to single and last results. Obviously, I wasn't quite there.