Count No of Text in a cells

Aradhika

New Member
Joined
Jul 20, 2019
Messages
11
Hi,

I am new to Power Bi and learning DAX.
Well, i have scenario below:

Table1
Column A Results
BP,SUGAR,DIABETES,HYPERTENSION 4
BP,SUGAR,DIABETES 3

Here, i want to count no of words(BP,SUGAR,DIABETES) are there in a cell.

Please help...

Thanks in advance
Ravi
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Hi,

I am new to Power Bi and learning DAX.
Well, i have scenario below:

Table1
Column A Results
BP,SUGAR,DIABETES,HYPERTENSION | 4
BP,SUGAR,DIABETES | 3

Here, i want to count no of words(BP,SUGAR,DIABETES) are there in a cell.

Please help...

Thanks in advance
Ravi
 
Upvote 0
Hi Aradhika,

You can try an old Excel trick for this DAX formula:
Rich (BB code):
CountWords = LEN(Table1[Column A]) - LEN(SUBSTITUTE(Table1[Column A], ",", "")) + 1

The main part is counting how many times a comma (",") appears in a word, then we need to add +1 at the end of the formula to return the actual number of words.

1585414020144.png
 

Attachments

  • 1585414026030.png
    1585414026030.png
    9.9 KB · Views: 2
Upvote 0
with Power Query and without duplicating worksheet formula
SplitCount = Table.AddColumn(Source, "SCount", each List.Count(Text.Split([raw],",")))
rawSCount
BP,SUGAR,DIABETES,HYPERTENSION4
BP,SUGAR,DIABETES3

simply add Custom Column, name it (here: SCount) and use: List.Count(Text.Split([raw],",")) inside
 
Last edited:
Upvote 0
Thank you very much.... JustynaMk & Sandy666

I have used above code and implemented in my project ... :)

Once again thanks, for your prompt reply and efforts.
Aradhika
 
Upvote 0

Forum statistics

Threads
1,214,585
Messages
6,120,399
Members
448,958
Latest member
Hat4Life

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