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
Anonymous
Not applicable

Calculated column duplicates

Hello

Could someone help me with a calculated column to record a fact table, if two columns are equal then 1, but if they have already existed once then 0 as in the image below in the output column.

Duplicate deletion cannot occur, as these are rows of data with more columns.

Row 1Row 2exit
111
221
220
331
220

Thank you

Liam

1 ACCEPTED SOLUTION
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can add Index in Power Query or use an existing if you have one, and later add the column as per below.

 

Column = 
VAR __row1 = 'Table'[Row 1]
VAR __index = 'Table'[Index]
RETURN 
INT( 
    IF(
        __row1 = 'Table'[Row 2],
        COUNTROWS(
            FILTER(
                'Table',
                'Table'[Index] < __index 
                && 'Table'[Row 1] = __row1
                && 'Table'[Row 2] = __row1
            )
        ) = 0
    )
)

 

The result will be 
image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

View solution in original post

3 REPLIES 3
Mariusz
Community Champion
Community Champion

Hi @Anonymous 

 

You can add Index in Power Query or use an existing if you have one, and later add the column as per below.

 

Column = 
VAR __row1 = 'Table'[Row 1]
VAR __index = 'Table'[Index]
RETURN 
INT( 
    IF(
        __row1 = 'Table'[Row 2],
        COUNTROWS(
            FILTER(
                'Table',
                'Table'[Index] < __index 
                && 'Table'[Row 1] = __row1
                && 'Table'[Row 2] = __row1
            )
        ) = 0
    )
)

 

The result will be 
image.png

Best Regards,
Mariusz

If this post helps, then please consider Accepting it as the solution.

Please feel free to connect with me.
LinkedIn

 

amitchandak
Super User
Super User

@Anonymous , if logic is based row1 and row 2, it is not very clear

Anonymous
Not applicable

Hi @amitchandak ,

 

I just needed the system to pick up on a match and if its already happened somehow,

 

I dont know whether thats possible

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.