Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Chrisblanc
Regular Visitor

COUNTIF formula to PowerBI

Hi all !

 

As you can see in the screenshot below, I have different titles in one colomn that I would like to sort into 2 categories. I have written the formula in Excel but I don't know how to translate it to Power BI (especially because of the function COUNTIF). 

 

Excel screenshot

 

Here is the Formula I wrote in Excel : 

=IF(OR(COUNTIF([@[Raw Title]],"Mr"),(COUNTIF([@[Raw Title]],"Heer"))),"Men","Women")

 

Thank you in advance for you help ! 

 

 

1 ACCEPTED SOLUTION
yelsherif
Resolver IV
Resolver IV

Basically, COUNTIF os translated into CALCULATE(COUNT(countable item/column), <condition>)

So, depending on whether you want the calculation as an added column or as a measure, the direct translation will look like

 

=IF(CALCULATE(COUNT(Table1[Raw Title]),Table1[Raw Title]="Mr")>0, "Men", "Women")

 

and alternatively, you can simply write the following calculated column

NewColumn = if(or([Raw Title]="Mr", [Raw Title]="Heer"), "Men", "Women")

Then a new measure to count Men and Women if needed

View solution in original post

2 REPLIES 2
yelsherif
Resolver IV
Resolver IV

Basically, COUNTIF os translated into CALCULATE(COUNT(countable item/column), <condition>)

So, depending on whether you want the calculation as an added column or as a measure, the direct translation will look like

 

=IF(CALCULATE(COUNT(Table1[Raw Title]),Table1[Raw Title]="Mr")>0, "Men", "Women")

 

and alternatively, you can simply write the following calculated column

NewColumn = if(or([Raw Title]="Mr", [Raw Title]="Heer"), "Men", "Women")

Then a new measure to count Men and Women if needed

I knew it was simple I was complicating everything for nothing. Thank you so much you just saved me from burnout 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.