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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Need to tag Original duplicate in dax function

Need to tag Original duplicate in dax function, example below, thanks in advance.

req.PNG

2 ACCEPTED SOLUTIONS
Fowmy
Super User
Super User

@Anonymous 

I cannot think of a solution in DAX for this problem.
You need a supporting column that identifies the order/sort, I added an index column and completed it in Power Query itself. 

Fowmy_0-1621670686061.png

Paste the below code on a new blank query in the Advanced Editor and see the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLSNTDVNTJU0lEyNFCK1aGiiDFcxIjKIiZwEWOyRWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}},"en-gb"),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Date"}, {{"Count", each _, type table [Date=nullable date, Value=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count],"Index",1) ),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Date", "Value", "Index"}, {"Date", "Value", "Index"}),
    #"Added Conditional Column" = Table.AddColumn(#"Expanded Custom", "Custom", each if [Index] = 1 then "Original" else "Duplicate"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"Index"})
in
    #"Removed Columns"

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

Add a index column in Power Query, then try to create a measure like below:

_Tag =
IF (
    CALCULATE (
        COUNT ( 'Table'[Date] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Date], 'Table'[Value] ),
            [Index] <= MAX ( [Index] )
        )
    ) = 1,
    "Original",
    "Duplicate"
)

Result:

v-angzheng-msft_0-1621919396820.png

 

 

Best Regards,
Community Support Team _ Zeon Zheng
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

2 REPLIES 2
v-angzheng-msft
Community Support
Community Support

Hi, @Anonymous 

Add a index column in Power Query, then try to create a measure like below:

_Tag =
IF (
    CALCULATE (
        COUNT ( 'Table'[Date] ),
        FILTER (
            ALLEXCEPT ( 'Table', 'Table'[Date], 'Table'[Value] ),
            [Index] <= MAX ( [Index] )
        )
    ) = 1,
    "Original",
    "Duplicate"
)

Result:

v-angzheng-msft_0-1621919396820.png

 

 

Best Regards,
Community Support Team _ Zeon Zheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Fowmy
Super User
Super User

@Anonymous 

I cannot think of a solution in DAX for this problem.
You need a supporting column that identifies the order/sort, I added an index column and completed it in Power Query itself. 

Fowmy_0-1621670686061.png

Paste the below code on a new blank query in the Advanced Editor and see the steps.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjLSNTDVNTJU0lEyNFCK1aGiiDFcxIjKIiZwEWOyRWIB", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Value", Int64.Type}},"en-gb"),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Date"}, {{"Count", each _, type table [Date=nullable date, Value=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count],"Index",1) ),
    #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"Date", "Value", "Index"}, {"Date", "Value", "Index"}),
    #"Added Conditional Column" = Table.AddColumn(#"Expanded Custom", "Custom", each if [Index] = 1 then "Original" else "Duplicate"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"Index"})
in
    #"Removed Columns"

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors