Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
jgpbi
Helper I
Helper I

Assign changing text cell a value for conditional formatting

I have seen all the example of how to change the text by assigning a value a number by adding a column or using SWITCH but these examples assume you know the values ahead of time. 

 

How would you do this if a given text column's data is unknown but many cells are identical?

Can you search and assign a unique number to each different cell value? 

 

jgpbi_0-1682347897651.png

 

i.e. - Beta = 1, Prod = 2....but those names may be different the next time.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @jgpbi ,

 

According to your description, here are my steps you can follow as a solution.

(1)My test data is the same as yours.

(2) We can create a calculated column.

Column = RANKX('Table','Table'[Cluster],,ASC,Dense)

(3) Then the result is as follows.

vtangjiemsft_0-1682479403343.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

View solution in original post

3 REPLIES 3
jgpbi
Helper I
Helper I

That worked perfectly. I had to do it via the Data View - New Column.

I still don't understand why certain functions to create a column only work from Data View - New Column and not from Transform Data - Add Column.

Anonymous
Not applicable

Hi @jgpbi ,

 

Click "transform data" to enter the power query editor, click "Advanced Editor" to copy and paste the following content, please check the steps from the right column, if you need to change the data source, please change the data source directly in the first step, and then go to the last step.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnINcVSK1cHGCAjyd8HD0HUMCNANd3WiroALfnZJanFJYiI2ZlKSUmwsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Cluster = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Cluster", type text}}),
    #"Removed Duplicates" = Table.Distinct(#"Changed Type"),
    #"Added Index" = Table.AddIndexColumn(#"Removed Duplicates", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

vtangjiemsft_0-1682561694504.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Anonymous
Not applicable

Hi @jgpbi ,

 

According to your description, here are my steps you can follow as a solution.

(1)My test data is the same as yours.

(2) We can create a calculated column.

Column = RANKX('Table','Table'[Cluster],,ASC,Dense)

(3) Then the result is as follows.

vtangjiemsft_0-1682479403343.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.