Forum Discussion
Formatting a column into negative numbers based on response from another column
Hi everyone, hope you're well. I have a sharepoint list where several of the columns are in multiple choice format. There is one such column, where there are 4 choices. One of these choices is O. After these columns, there are non multiple choice columns where the user has to manually enter a number.
I want it to be so that on the non multiple choice columns, where the user enters a number, the number automatically becomes a negative number if, on that same row, on the previous aforementioned column, the user chooses O. Is this possible?
Of course, they can just enter a negative number themselves, but given how fast and frequently they have to enter these numbers, a few times it can be subject to human error, and so I'm looking to find out if the above is possible. I'm fairly new to sharepoint.
Thanks in advance for your help 🙂
Imam1375 Do you just want to just want to show the negative numbers in list view OR you want to store the negative value in actual column & use it somewhere else (custom application/power apps/power automate, etc?).
If you just want to show it in list view, you can use column formatting for this. Here's a JSON code you can use for the same:{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=if(indexOf(join([$MultiChoice], '|'), 'O') >=0, if(@currentField < 0, @currentField, @currentField * -1), @currentField)" }
Output:
I have added above JSON code on MyNoColumn field. Also, you have to use the internal name of your multiple selection choice column in place of MultiChoice in above code.
Follow this article to get the internal name of your SharePoint column: 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.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
2 Replies
Imam1375 Do you just want to just want to show the negative numbers in list view OR you want to store the negative value in actual column & use it somewhere else (custom application/power apps/power automate, etc?).
If you just want to show it in list view, you can use column formatting for this. Here's a JSON code you can use for the same:{ "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json", "elmType": "div", "txtContent": "=if(indexOf(join([$MultiChoice], '|'), 'O') >=0, if(@currentField < 0, @currentField, @currentField * -1), @currentField)" }
Output:
I have added above JSON code on MyNoColumn field. Also, you have to use the internal name of your multiple selection choice column in place of MultiChoice in above code.
Follow this article to get the internal name of your SharePoint column: 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.
For SharePoint/Power Platform blogs, visit: Ganesh Sanap Blogs
- MagnusGoksoyrOLDProfileBronze ContributorHopefully you can solve it after looking into this: https://docs.microsoft.com/en-us/sharepoint/dev/declarative-customization/column-formatting