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

Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more

Reply
RanjeetK
Helper I
Helper I

Count Duplicate records with multiple columns

Hello , i need help to solve following problem.
i need count of Audit ID which are having duplicate records. Like every audit ID have a different Activity key but some of them are repeated 
EX :- 100,2345,4,
so i need to create a measure which gives me count of records = 2 

Audit IDActivity IDActivity RC Cycle
10023454
10023454
10023464
10023474
10023484
100045675
100045685
20065431
20065431

Output 

Audit IDActivity IDActivity RC CycleMeasure
100234541
200654311
Total  2
1 ACCEPTED SOLUTION
RanjeetK
Helper I
Helper I

Hey Hi All ,
I got solution 

Var _Count = ADDCOLUMNS(SUMMARIZE(data,data[Audit ID],data[Activity ID],data[Activity RC Cycle]),
"@Count",CALCULATE(COUNTA(data[Activity RC Cycle]),ALLSELECTED(data[Audit ID]))
)

Var _Greaterthan = FILTER(_Count,[@Count]>=2)
Var _Result = COUNTROWS(_Greaterthan)
RETURN
_Result


RanjeetK_0-1666879762337.png

 

 

View solution in original post

6 REPLIES 6
RanjeetK
Helper I
Helper I

Hey Hi All ,
I got solution 

Var _Count = ADDCOLUMNS(SUMMARIZE(data,data[Audit ID],data[Activity ID],data[Activity RC Cycle]),
"@Count",CALCULATE(COUNTA(data[Activity RC Cycle]),ALLSELECTED(data[Audit ID]))
)

Var _Greaterthan = FILTER(_Count,[@Count]>=2)
Var _Result = COUNTROWS(_Greaterthan)
RETURN
_Result


RanjeetK_0-1666879762337.png

 

 

RanjeetK
Helper I
Helper I

@Mikelytics , Thanks for your efforts 
but it does not work , i have tried it in my data as you can see 

Measure 2 = SUMX(
                 VALUES(data[Activity ID]),
                 Var Var_All = CALCULATE(
                                         COUNTROWS(data),
                                         ALLEXCEPT(data,data[Activity ID])
                                        )
                                  Return
                                  IF(Var_All>1,Var_All-1,BLANK()
                                  ))
It returns Blank 
RanjeetK_0-1666874771843.png

Please share your file if possible and thanks for immediate reply

Hi Ranjeet,

 

I checked again and please follow the steps below.

 

1) this is my starting table with redundant line-items

Mikelytics_4-1666876272090.png

 

2) Make sure that all columns are text

Mikelytics_5-1666876309299.png

 

 

3) Create a key column for your duplication tracking with the formula:

[Audit ID] & "_" & [Activity ID] & "_" &[Activity RC Cycle]

Mikelytics_6-1666876327637.png

 

1st result

Mikelytics_7-1666876359951.png

 

now load the table and create the following measure

 

CycleMeasure = 
SUMX(
    VALUES('Test Table'[KeyColumn]),
    Var Var_All = 
        CALCULATE(
            COUNTROWS('Test Table'),
            ALLEXCEPT('Test Table','Test Table'[KeyColumn])
        )
    Return
    IF(Var_All>1,Var_All-1,BLANK()
    )
)

Mikelytics_9-1666876514409.png

 

now it should work 🙂

Mikelytics_10-1666876553539.png

 

Best regards

Michael

 

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

 

 

 

 

 

 

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Hey Hi Mikelytics,
Ohhh Nice trick Mike !!! this could be the solution but..........
Yes it works in Import  and Direct query mode but it does not work in Live Connection where we can use Virtual approach only, we can only create measures not a calculated column.
if possiable can you please suggest me how to do that? or anyone have such example please

Shaurya
Memorable Member
Memorable Member

Hi @RanjeetK,

 

Use the following formula to identify the records that are duplicates:

 

Count = SUMX('Table',IF('Table'[Audit ID]=EARLIER('Table'[Audit ID])&&'Table'[Activity ID]=EARLIER('Table'[Activity ID])&&'Table'[Activity RC]=EARLIER('Table'[Activity RC]),1))

 

Then summarize the original table after filtering out the non-duplicate rows:

 

Duplicates = SUMMARIZE(FILTER('Table','Table'[Count]>1),'Table'[Audit ID],'Table'[Activity ID],'Table'[Activity RC],"Measure",1)

 

Works for you? Mark this post as a solution if it does!
Consider taking a look at my blog: Forecast Period - Previous Forecasts

Hi Shaurya,
this will work for calculated column ,
Actually i am using Live connection so i can't create a calculated Column but yes we can do it in Virtual Table approach ( create View similar as in SQL and then use it)
thanks for your Efforts Bro 👍👍 !!!!!

Helpful resources

Announcements
Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors