0

I have a SP list, one of the columns contains different numbers. I need to replace these numbers with text.

For instance, if column color contains:

1 -> replace it with the text white

2 -> replace it with the text black

And so on, is there a simple PowerApp that can be manually triggered to do that?

I tried using the following JSON for the column:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "txtContent": "=if(@currentField == 1, 'white', if(@currentField == 2, 'Black', ''))"
}

but when filtering the column, it will show the numbers 1,2,etc instead of the text (white, black, etc..).

1 Answer 1

0

This is the expected behavior in SharePoint while using JSON Formatting as JSON formatting only customizes the "display" of the list column and does not store/modify the actual value of column.

So while filtering on column you will see the actual values instead of JSON formatted values.


For your requirements, you can use calculated columns in SharePoint.

Use below formula in calculated column:

=IF([Column1] = 1, "White", IF([Column1] = 2, "Black", ""))

Where [Column1] is the name of your number column.

5
  • The column is Text single line. I tried running a flow using: replace(outputs('ComposeTitle'),'1','white') - but could not figure out how to modify replace so it check for other options, like replace(outputs('ComposeTitle'),'1','white'), replace(outputs('ComposeTitle'),'2','black') etc...
    – Sarmad
    Jun 25, 2022 at 14:27
  • If column is single line text, you can use formula like: =IF(Value([Column1]) = 1, "White", IF(Value([Column1]) = 2, "Black", "")) Jun 25, 2022 at 18:29
  • Thanks Ganesh, do I need to add it under Column Formatting in SP list?
    – Sarmad
    Jun 26, 2022 at 7:14
  • No, create a new column with "Calculated" as data/column type and use above formula for calculation. Replace Column1 with actual name of your number column. Jun 26, 2022 at 7:18
  • Hi @Sarmad, does this answers your question? If yes, please Upvote(^) and accept as an Answer as it helped you & it will help others with similar question in future to find the correct answer easily. It also removes this question from "Unanswered questions" list. Aug 23, 2022 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.