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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
tbj1011
Regular Visitor

Generate unique ID from various columns

Hello,

 

I have 8 columns of financial system account data (approx 45 digits total). I need to generate a unique ID of 8 digits for each unique combination of the other 8 columns.

 

Any suggestions?

 

Thanks

7 REPLIES 7
AlexisOlson
Super User
Super User

It's generally easier to create an index rather than a suitable hash value.

 

Also, be aware that restricting to 8 decimal digits limits you to no more than 1 million unique IDs, so you'll need to worry about hash collisions if your data is close to that size or larger.

I've used indices before - unfortunately, in this case, the 8-digit number needs to be a "shorthand" version of the longer account string so that it can readily identify the account. I shouldn't wind up with more than a few hundred of these IDs - no worries about millions.

Uniquely representing 8 different structures corresponding to 8 digits won't be possible unless all of these structures have 10 or fewer distinct values. Even if this is the case, you'd have to map, e.g., "52305" and "52210" to a single digit, in which case it won't be a shorthand since you cannot map both of these to "5".

smpa01
Super User
Super User

@tbj1011  is it kindly possible to provide some sample data?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Fund                     1000                     1000

Function              03                          03

Department        300                       300

Division                5100                     5100

Function     52210                   52305

Subfunction 005                       001

Location              5100                     5100

Program              0000                     0000

 

So, these two accounts differ by function and subfunction. However, I have thousands of accounts that differ on every one of the 8 account structures. I need an 8-digit "code" to identify unique accounts.

@tbj1011  you can try something like this

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcivNS1HSUTI0MDCAUbE6YOHkksz8PKCYgTGEAAm7pBYkFpXkpuaVAMWMwVqMoTpcMssyiyE6TA3BMmAKzTBTIyNDsJyRsYEpWDK4NCkNyTKgKIg0BMv55CcnlmA3M6AoP70oMResGCwDpmJjAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [CAT = _t, Value1 = _t, Value2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"CAT", type text}, {"Value1", type text}, {"Value2", type text}}),
    src=Table.RemoveColumns(#"Changed Type",{"CAT"}),
    DH = Table.DemoteHeaders(src),
    ColNames = Record.ToList(DH{0}),
    Loop = List.Generate(
()=>[i=0,j=try Text.Combine(List.Difference(Table.Column(src,ColNames{i}),Table.Column(src,ColNames{i+1}))) otherwise "last"],
each [i]<List.Count(ColNames),
each [i=[i]+1,j=try Text.Combine(List.Difference(Table.Column(src,ColNames{i}),Table.Column(src,ColNames{i+1}))) otherwise "last"],
each [j]
)
in
    Loop

 

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

@tbj1011  so if you have 5 accounts in the dataset , how does the dataset look?

Did I answer your question? Mark my post as a solution!
Proud to be a Super User!
My custom visualization projects
Plotting Live Sound: Viz1
Beautiful News:Viz1, Viz2, Viz3
Visual Capitalist: Working Hrs

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Fabric Monthly Update - May 2024

Check out the May 2024 Fabric update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors