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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
sjpbi
Frequent Visitor

How to create column that counts the specific duplicate entry in the table

Hi, need help on How to create column that counts the specific duplicate entry in the table?

 

Here's my sample data table

IDRequestID
013D34567
023S56789
056F98765
013R34567
098T98765
067H67843

 

 

Need to have this count column in pbi dax referencing from request id and id to count the first entry as 1

IDRequestIDCount
013D345671
023S567891
056F987651
013R345672
098T987652
067H678431
1 ACCEPTED SOLUTION
v-kaiyue-msft
Community Support
Community Support

Hi @sjpbi ,

Please follow these steps:

1.In Power Query -- add Column – Index Column – From 1.

vkaiyuemsft_0-1706685503976.jpeg

the results are shown below.

vkaiyuemsft_1-1706685533008.png

2.Create a calculated column and write the following expression.

 

 

Count Column = COUNTROWS(FILTER('Table','Table'[RequestID] = EARLIER('Table'[RequestID]) && 'Table'[Index] <= EARLIER('Table'[Index])))

 

 

3.The final result is shown below.

vkaiyuemsft_2-1706685564223.png

If you don't want the index column to appear in the report, you can hide it by clicking on the small eye to its right.

vkaiyuemsft_3-1706685564224.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

4 REPLIES 4
v-kaiyue-msft
Community Support
Community Support

Hi @sjpbi ,

Please follow these steps:

1.In Power Query -- add Column – Index Column – From 1.

vkaiyuemsft_0-1706685503976.jpeg

the results are shown below.

vkaiyuemsft_1-1706685533008.png

2.Create a calculated column and write the following expression.

 

 

Count Column = COUNTROWS(FILTER('Table','Table'[RequestID] = EARLIER('Table'[RequestID]) && 'Table'[Index] <= EARLIER('Table'[Index])))

 

 

3.The final result is shown below.

vkaiyuemsft_2-1706685564223.png

If you don't want the index column to appear in the report, you can hide it by clicking on the small eye to its right.

vkaiyuemsft_3-1706685564224.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

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

 

Ritaf1983
Super User
Super User

Hi @sjpbi 
I think that this is much easier to solve from a power query, take a look at the linked tutorial:
https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query

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

Ashish_Mathur
Super User
Super User

Hi,

It is fairly easy to do this in the Query Editor.  If you are OK with using the Query Editor, then post back.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
amitchandak
Super User
Super User

@sjpbi , Try with new Dense Rank function in a measure

 

Date would be a better option for order by, you can use if ([New Rank Desne]>= 2, 2,1)

 

New Rank Desne = rank(DENSE,ALLSELECTED(Table[ID],Table[RequestID]),ORDERBY(Table[RequestID],asc),, partitionBy(Table[ID]) )

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.