Forum Discussion

Imam1375's avatar
Imam1375
Copper Contributor
Jul 27, 2022
Solved

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. Aft...
  • ganeshsanap's avatar
    Jul 28, 2022

    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

Resources