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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
unnijoy
Post Prodigy
Post Prodigy

Calculated column to avoid duplicate UID

I got a table with ID, Year , UID. Below is the sample table.

UIDYear IDFina ID
202023202023202023
202023202023 
202023202023 
202023202023 
202124202124202124
202124202124 
202125202125 
202125202125202125

 Now i need to create a new column ("Final ID"). The issue is that if the UID is repeating then that UID should come only once in the new Column.
Can anyone suggest and idea.

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @unnijoy ,

 

Try like below:

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIAQmMlHTADRBkrxepQT9jQyAQibAiiTAgKmyIJm+IUjgUA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, Category = _t, Year = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"Category", type text}, {"Year", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Country", "Category"}, {{"Rows", each _, type table [Country=text, Category=text, Year=number, Value=number]}}),
Indexed = Table.TransformColumns(#"Grouped Rows", {{"Rows", each Table.AddIndexColumn(_,"GroupIndex", 1, 1)}}),
#"Expanded Rows" = Table.ExpandTableColumn(Indexed, "Rows", {"Year", "GroupIndex"}, {"Year", "GroupIndex"}),
    #"Renamed Columns" = Table.RenameColumns(#"Expanded Rows",{{"Country", "UID"}, {"Year", "ID"}, {"Category", "Year"}})
in
    #"Renamed Columns"
Final ID = IF(Table1[GroupIndex] = "1",Table1[UID],BLANK())

vhenrykmstf_0-1662605106543.png

 

If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


Best Regards,
Henry


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

 

 

@v-henryk-mstf ,  Mine is a calculated table. so it won;t come in Query Editor... Can you tell me how i can add the group index column.

unnijoy
Post Prodigy
Post Prodigy

In excel we can do it by Final ID=IF(A1=C1,"",A1). But how can we do that with Dax.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.