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
Mee2105
Frequent Visitor

What is the COUNTIF counterpart in Power BI?

hello, 

 

What is the PowerBI counterpart of =COUNTIF, please?

 

in my excel file,  I am using =IF(COUNTIF([@Tags],"*mango*"), "yes","no")to pick out  the word 'mango' and of they are present mark them as 'yes', else 'no'.

 

Thanks in advance.

 

2 ACCEPTED SOLUTIONS

That formula is for a measure, if you're creating a column with DAX you can leave out the MAX portion of that!

View solution in original post

v-rzhou-msft
Community Support
Community Support

Hi @Mee2105 ,

 

As far as I know, your code should mean that if data in [@Tags] contains "mango" then return "yes" else return "no".

vrzhoumsft_0-1690879719441.png

You can try code as below to create a calculated column.

Column = IF(CONTAINSSTRING('Table'[Tags],"mango"),"yes","no")

Result is as below.

vrzhoumsft_1-1690879938979.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
v-rzhou-msft
Community Support
Community Support

Hi @Mee2105 ,

 

As far as I know, your code should mean that if data in [@Tags] contains "mango" then return "yes" else return "no".

vrzhoumsft_0-1690879719441.png

You can try code as below to create a calculated column.

Column = IF(CONTAINSSTRING('Table'[Tags],"mango"),"yes","no")

Result is as below.

vrzhoumsft_1-1690879938979.png

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much, this works

Syk
Super User
Super User

If you're just trying to count mangos, you can use calculate.

 

Mango Count = CALCULATE(COUNT('Table'[id]),'Table'[Tags] = "mango")

Calculate is a filter function that uses your second argument (in this case, 'Table' [Tags]="mango") to filter your first argument.
If you are trying to mark them yes/no, we could do that too it just depends on what you're looking for.

Mee2105
Frequent Visitor

Also, why isnt it accepting =CALCULATE as a formula?

Mee2105_0-1690467826022.png

 

You need to put a name.

Mee2105
Frequent Visitor

Thank you for the solution.

 

is there a way to mark them as 'yes' and 'no' in another column? 

Yes. It would look like

is Mango = IF(MAX('Table'[Tag])="mango","Yes","No")

That formula is for a measure, if you're creating a column with DAX you can leave out the MAX portion of that!

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.