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
mamoormasoomi
Helper I
Helper I

Counting text occurrences in a colum with in the same table

Hi,

 

I have been trying to get the result  like the below first table in Countkey field. So far I am only able to get the total no. in the count key firled instead of getting the series of # upon the occrance of similar text in Key 1 field. Please check the below 2nd screenshot for the  formula ( Countkey = CALCULATE (COUNT(SHEE1[KEY 1]))  and result so far getting from power bi.

 

Required Result Table

Key 1Countkey
AB1
AC1
AD1
AE1
AE2
AF1
AG1
AG2
AG3
AG4
AH1
AH2
AI1

 

Getting so far from Power BI.

 

Power BI2.jpg

1 ACCEPTED SOLUTION

@mamoormasoomi

Have you ever tried my solution in your previous thread? Besides that solution(in a attached pbix), you can also try

Result Key_ = RANKX(FILTER('Table','Table'[Key1]=EARLIER('Table'[Key1])),'Table'[Index],,ASC,Dense)

Capture.PNG

View solution in original post

3 REPLIES 3
vanessafvg
Super User
Super User

@mamoormasoomi

 

are you wanting a cummulative total?

 

how do you want it ordered? if you dont have a column to order it, you can create an index column in power query

 

cummulativecount = CALCULATE(countrows(Table1), FILTER(all(Table[Index]), Table1[Index] <= MAX(Table[Index])))

 

if you do that something like this should work





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




 

Thanks for your reply but I am still not getting the result the desired result.

 

I tried to used your provided code and added the index column too but the result is coming up like the below. The first repeated word "AE" is coming three times so when the first time AE comes then the corresponding column (Cummulativecount) should say value "1" then when the point move to the next row it should say "2"  same action should be done with word 'AG" that came 4 times in the column.

 

 

Power BI3.jpg

 

I want the the way like the below screenshot where the color highlighted areas are showing the occurence of similar texts with corresponding values in the Countkey field.

 

Power BI4.jpg

 

 

@mamoormasoomi

Have you ever tried my solution in your previous thread? Besides that solution(in a attached pbix), you can also try

Result Key_ = RANKX(FILTER('Table','Table'[Key1]=EARLIER('Table'[Key1])),'Table'[Index],,ASC,Dense)

Capture.PNG

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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