Flagging duplicates but Serial wise

Shaikh Aziz

New Member
Joined
Dec 18, 2020
Messages
35
Office Version
  1. 2007
Platform
  1. Windows
Hi there,

I want to identify duplicates but serial wise e.g. in normal excel I would do =COUNTIF($A$2:A2,A2),
How do I apply same countif condition in Power Query ? Please suggest or help any easy way to complete the task.
I am attaching the result normal excel image.
 

Attachments

  • Sample-1.jpg
    Sample-1.jpg
    78.7 KB · Views: 8

Excel Facts

Select all contiguous cells
Pressing Ctrl+* (asterisk) will select the "current region" - all contiguous cells in all directions.
Book1
ABCDEFGHIJKLMNOP
1Product NameBusiness TypeAgeSl BandPolicy countColumn1PrmProduct NameBusiness TypeAgeSl BandPolicy countColumn1PrmCount
21234567Fresh0-53 lacs13841234567Fresh0-53 lacs13841
36785390Renewal20-May6 Iacs31646785390Renewal450666 Iacs31643
45678903Rollover21-259 Iacs12156785390Rollover0-53 Iacs24873
5875938Fresh25-3012 Iacs21926785390Renewal21-259 Iacs14243
65678903Renewal30-3515 Iacs33935678903Rollover21-259 Iacs12152
76785390Rollover0-53 Iacs24875678903Renewal30-3515 Iacs33932
85765282Fresh20-May6 Iacs2491875938Fresh25-3012 Iacs21921
96785390Renewal21-259 Iacs14245765282Fresh450666 Iacs24911
10903876Rollover25-3012 Iacs3312903876Rollover25-3012 Iacs33123
116755493Fresh30-3515 Iacs21866755493Fresh30-3515 Iacs21861
126547382Renewal0-53 Iacs31716547382Renewal0-53 Iacs31711
13345267Rollover20-May6 Iacs1481345267Rollover450666 Iacs14811
14903876Renewal21-259 Iacs3268903876Renewal21-259 Iacs32683
15567290Rollover25-3012 Iacs1173567290Rollover25-3012 Iacs11731
16903876Renewal30-3515 Iacs2459903876Renewal30-3515 Iacs24593
Sheet1

Using Group By to get the count:
Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ProdCount =  Table.Group(Source, {"Product Name"}, {{"Count", each Table.RowCount(Table.Distinct(_)), Int64.Type}}),
    MergedQueries = Table.NestedJoin(Source, {"Product Name"}, ProdCount, {"Product Name"}, "ProdCount", JoinKind.LeftOuter),
    ExpandedProdCount = Table.ExpandTableColumn(MergedQueries, "ProdCount", {"Count"}, {"Count"})
in
    ExpandedProdCount

Hope that helps.
 
Upvote 0
Thanks for revert,
By adding above mentioned query I am getting same count of each values, e.g., if you will look product name "6785390" for each product name it's providing the same results as "3" counts. I want it in serial wise, e.g., product name wise serial count.
Your understanding is greatly appreciated.
 
Upvote 0
Thanks for revert,
By adding above mentioned query I am getting same count of each values, e.g., if you will look product name "6785390" for each product name it's providing the same results as "3" counts. I want it in serial wise, e.g., product name wise serial count.
Your understanding is greatly appreciated.
It is very difficult to work with a tiny screenshot, and I wasn't paying attention to the CountIf column since what I thought you were saying was that you just wanted a count. What you meant was you want a Running Total, and had you used XL2BB it might have been more apparent.
Anyway, this video shows how to do a running total. I think I have it now:
Book1
IJKLMNOP
1Product NameBusiness TypeAgeSl BandPolicy countPrmCountifRT
21234567Fresh0-53 lacs138411
36785390Renewal5-206 Iacs316411
45678903Rollover21-259 Iacs121511
5875938Fresh25-3012 Iacs219211
65678903Renewal30-3515 Iacs339322
76785390Rollover0-53 Iacs248722
85765282Fresh5-206 Iacs249111
96785390Renewal21-259 Iacs142433
10903876Rollover25-3012 Iacs331211
116755493Fresh30-3515 Iacs218611
126547382Renewal0-53 Iacs317111
13345267Rollover5-206 Iacs148111
14903876Renewal21-259 Iacs326822
15567290Rollover25-3012 Iacs117311
16903876Renewal30-3515 Iacs245933
Sheet1

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ChangedType = Table.TransformColumnTypes(Source,{{"Product Name", Int64.Type}, {"Business Type", type text}, {"Age", type text}, {"Sl Band", type text}, {"Policy count", Int64.Type}, {"Prm", Int64.Type}, {"Countif", Int64.Type}}),
    AddedIndex = Table.AddIndexColumn(ChangedType, "Index", 1, 1, Int64.Type),
    BufferedTable = Table.Buffer(AddedIndex),
    #"Added Custom" = Table.AddColumn(BufferedTable, "RT", (OT) => Table.RowCount( Table.SelectRows( BufferedTable, (IT) => IT[Product Name] = OT[Product Name] and IT[Index] <= OT[Index] ) ), Int64.Type  ),
    RemovedIndex = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    RemovedIndex
I think that's what you're looking for. I hope so!
 
Upvote 1
Solution
It is very difficult to work with a tiny screenshot, and I wasn't paying attention to the CountIf column since what I thought you were saying was that you just wanted a count. What you meant was you want a Running Total, and had you used XL2BB it might have been more apparent.
Anyway, this video shows how to do a running total. I think I have it now:
Book1
IJKLMNOP
1Product NameBusiness TypeAgeSl BandPolicy countPrmCountifRT
21234567Fresh0-53 lacs138411
36785390Renewal5-206 Iacs316411
45678903Rollover21-259 Iacs121511
5875938Fresh25-3012 Iacs219211
65678903Renewal30-3515 Iacs339322
76785390Rollover0-53 Iacs248722
85765282Fresh5-206 Iacs249111
96785390Renewal21-259 Iacs142433
10903876Rollover25-3012 Iacs331211
116755493Fresh30-3515 Iacs218611
126547382Renewal0-53 Iacs317111
13345267Rollover5-206 Iacs148111
14903876Renewal21-259 Iacs326822
15567290Rollover25-3012 Iacs117311
16903876Renewal30-3515 Iacs245933
Sheet1

Power Query:
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    ChangedType = Table.TransformColumnTypes(Source,{{"Product Name", Int64.Type}, {"Business Type", type text}, {"Age", type text}, {"Sl Band", type text}, {"Policy count", Int64.Type}, {"Prm", Int64.Type}, {"Countif", Int64.Type}}),
    AddedIndex = Table.AddIndexColumn(ChangedType, "Index", 1, 1, Int64.Type),
    BufferedTable = Table.Buffer(AddedIndex),
    #"Added Custom" = Table.AddColumn(BufferedTable, "RT", (OT) => Table.RowCount( Table.SelectRows( BufferedTable, (IT) => IT[Product Name] = OT[Product Name] and IT[Index] <= OT[Index] ) ), Int64.Type  ),
    RemovedIndex = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    RemovedIndex
I think that's what you're looking for. I hope so!
Thank you so much !! That's what I wanted ;)
 
Upvote 0

Forum statistics

Threads
1,223,957
Messages
6,175,623
Members
452,661
Latest member
Nonhle

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top