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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nipius
Advocate I
Advocate I

Creating unique value if value already exists

Hi all!

 

I have a query including a column with duplicate values. For the purpose of my table, I'd like to add another column where I add another character (for example "A" or "1") to the duplicate of a value.

 

For example, in case of

58379

58379

58379

58379

93850

39412

39412

 

I'd like the first value to keep as is, but change the other duplicates and ignore the unique values. The above would then result in

58379

58379A

58379AA

58379AAA

93850

39412

39412A

 

Is there a way for me to accomplish this? Thanks in advance!

1 ACCEPTED SOLUTION

@Nipius here you go, see attached, I added two unique columns one with _1, _2, _3 and so on and other with _A, _AA, _AAA and so on.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

9 REPLIES 9
parry2k
Super User
Super User

@Nipius copy these steps into your table using query editor.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrUwNrdUitUhxLI0tjA1ALOMLU0MjZBZsQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Id = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Id", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Id"}, {{"Count", each  Table.AddIndexColumn(_, "Rank", 0)}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Rank"}, {"Rank"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Expanded Count",{{"Rank", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type1", "New Id", each Number.ToText([Id]) &
(
if [Rank] > 0 then "-" & Number.ToText([Rank]) else ""
)),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Id", "Rank"})
in
    #"Removed Columns"


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Thanks @parry2k !

 

I've added this as a Custom Column, but there is not a reference to the particular column I want to get the values from. It now shows me the numbers I mentioned below, which was actually just an example. Am I missing something? 🙂

@Nipius if you share your full sample dataset it will help, I just gave you the solution based on what you posted originally.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k : Sure! Herewith the link to the file. It's on my personal NAS, as my organization does not allow to create shareable OneDrive links for persons outside the organization.

 

I've added the Position_Unique column manually for your reference, but this is in the end the result I'd like to get. Hopefully this makes sense.

@Nipius trying to download the file, stay tuned.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Nipius you also have to share xlsx file as I need it to perform transformation in power query



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@Nipius here you go, see attached, I added two unique columns one with _1, _2, _3 and so on and other with _A, _AA, _AAA and so on.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k Thanks a ton! This is exactly what I was looking for. Many thanks!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors