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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mderraz
New Member

Counting number of occurrences in a column and have the result in a separate column

Hi guys,

 

I have a column with countries and would like to count occurences in a spearate colum as shown below:

Countries        Occurence Count

France                           1

England                         1

Germany                       1

France                           2 

China                            1

France                           3

 

How can I create the "Occurence Count" column please?

 

Thanks!

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@mderraz 

 

First add an Index Column from Query Editor

 

Then you can Rank that Index for each Country to get the Occurrence Count as follows

 

Occurence Count =
RANKX (
    FILTER ( Table1, Table1[Countries] = EARLIER ( Table1[Countries] ) ),
    [Index],
    ,
    ASC
)

oc.png

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@mderraz 

 

First add an Index Column from Query Editor

 

Then you can Rank that Index for each Country to get the Occurrence Count as follows

 

Occurence Count =
RANKX (
    FILTER ( Table1, Table1[Countries] = EARLIER ( Table1[Countries] ) ),
    [Index],
    ,
    ASC
)

oc.png

Thanks Zubair! It worked perfectely, I didn't know Inderx column as I am still new using with Power BI.

One question though: my Dashboard takes now a lot more time to Refresh, could it be because of the Index column I added.

Seems like it's taking a lot of memory. Or is it something else?

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors