Advance your Data & AI career with 50 days of live learning, dataviz contests, hands-on challenges, study groups & certifications and more!
Get registeredJoin us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.
I have a column like this.
A
B
C
A
B
C
A
I want a second column with a count of how many of the values have been seen so far, just like this.
A 1
B 1
C 1
A 2
B 2
C 2
A 3
Solved! Go to Solution.
HI @Anonymous ,
Create a index column in your table then create a column with below code:-
Occurrences =
CALCULATE (
COUNT ([Column1] ),
FILTER (
ALL('Table (4)'),
[Index] <= EARLIER ( [Index] )
&& [Column1] = EARLIER ( [Column1] )
)
)
Output:-
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
HI @Anonymous ,
Create a index column in your table then create a column with below code:-
Occurrences =
CALCULATE (
COUNT ([Column1] ),
FILTER (
ALL('Table (4)'),
[Index] <= EARLIER ( [Index] )
&& [Column1] = EARLIER ( [Column1] )
)
)
Output:-
Thanks,
Samarth
Best Regards,
Samarth
If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin
@Anonymous change the column name in the script to the column name from your table
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmCSSJFYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"TagName", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"TagName"}, {{"Rank", each Table.AddIndexColumn(_, "Rank", 1)}}),
#"Expanded Rank" = Table.ExpandTableColumn(#"Grouped Rows", "Rank", {"Rank"}, {"Rank.1"})
in
#"Expanded Rank"
basically steps from #"Grouped Rows" is what you needed.
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k ,
Thanks, I tried this but I got an error saying the column "TagName" in the table wasn't found. Do I have to specify my table name somewhere? It is called Panel.
Referring to this link hope it will help you
Did I answer your question? If so, please mark my post as a solution!
Proud to be a Super User!
@Anonymous you should add a index column in Power Query, start a blank query in PQ, click advanced editor and paste this code
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclSK1YlWcgKTzmCSSJFYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column", type text}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Column"}, {{"Rank", each Table.AddIndexColumn(_, "Rank", 1)}}),
#"Expanded Rank" = Table.ExpandTableColumn(#"Grouped Rows", "Rank", {"Rank"}, {"Rank.1"})
in
#"Expanded Rank"
Learn about conditional formatting at Microsoft Reactor
My latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k , thanks for your reply. The letters I used were only an example. The column is more like shown below. Do you know how I can modify the code to count all the values in this column?
Note: This is just a snippet, there is around 40 unique tags that get repeated.
Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!
Check out the October 2025 Power BI update to learn about new features.
| User | Count |
|---|---|
| 76 | |
| 38 | |
| 31 | |
| 27 | |
| 26 |