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
Circuscazz
New Member

Calculate occurrance of a word in multiple columns using M in Power BI

Hi

I'm trying to add a column and count of the number of times the word Apple is found in specific columns in my table. 

 

I've tried the below but getting an error- Can you see where i have gone wroing

= Table.AddColumn(#"Renamed Columns2", "New Column", each List.Count (List.FindText({[#"column1"]},{[#"column2"]},{[#"column3"]},"Apple")))

 

Can anyone help?

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

List.Count just counts the items. It doesn't take any extra arguments about what items to count, so you need to filter the list before you count it.

 

Table.AddColumn(
  #"Renamed Columns2", "New Column",
  each List.Count(List.Select({[column1], [column2], [column3]}, each _ = "Apple"))
)

View solution in original post

2 REPLIES 2
Circuscazz
New Member

OK great will give that a try

 

AlexisOlson
Super User
Super User

List.Count just counts the items. It doesn't take any extra arguments about what items to count, so you need to filter the list before you count it.

 

Table.AddColumn(
  #"Renamed Columns2", "New Column",
  each List.Count(List.Select({[column1], [column2], [column3]}, each _ = "Apple"))
)

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors