General question about handling data in a table

abaker77

New Member
Joined
Oct 11, 2011
Messages
18
Office Version
  1. 365
I have a standard table; in which one of the fields contains a long descriptor. The descriptor may be any # of characters; there is no pattern at all within the descriptor.
I am trying to determine how I can create a short, unique, identifier for this field, to be used in reports, e.g. Pivot Tables. None of the other fields in the table are candidates for this; I need this identifier to come from the descriptor field.
One (silly) example of an identifier would be to simply extract the 1st character; so there might be 36 unique items, e.g. A-Z, 0-9; but hardly useful for reports.
Is there any way or technique, using either Power Query or a normal Excel function/formula which can produce a more reasonable unique identifier?
Thanks so much.
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
In similar circumstances I generate an MD5 hash using the following code:
VBA Code:
Function StringToMD5Hex(ByVal s As String) As String
Dim enc As Object
Dim bytes() As Byte
Dim pos As Long
Dim outstr As String

Set enc = CreateObject("System.Security.Cryptography.MD5CryptoServiceProvider")

bytes = StrConv(s, vbFromUnicode)
bytes = enc.ComputeHash_2(bytes)

For pos = LBound(bytes) To UBound(bytes)
   outstr = outstr & LCase(Right("0" & Hex(bytes(pos)), 2))
Next pos

StringToMD5Hex = outstr
Set enc = Nothing
End Function
Then in a new column of the table we may use the formula
Excel Formula:
=StringToMD5Hex([@Descrizione])
(adapt to your column name)
Copy the formula down, if it don't expand automatically

Now you may use this new column as the unique identifier
Try...
 
Upvote 0
Brilliant and quick response - thank you so much.
Realistically, I don't think any solution would work since the descriptions are so random. Obviously, your 32 char MD5 hash string works as a "unique identifier" but I was thinking more along the lines of something shorter and more user-friendly for reports. Thinking about it now, I don't think there can be a real solution to this.
Thanks anyway !
 
Upvote 0

Forum statistics

Threads
1,214,599
Messages
6,120,453
Members
448,967
Latest member
grijken

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top