cancel
Showing results 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.

Regular Visitor

## Convert COUNTIF in Excel to DAX

Hi,

I am relatively new to using DAX and was wondering if the below excel formula be converted into DAX?

=IF(COUNTIF('County Player List'!A:A,[@County])>0,"Yes", "No")

2 ACCEPTED SOLUTIONS
Super User

@sb2848 COUNTIF is COUNTX(FILTER(...),...) in DAX. CO-CU Excel to DAX Translation - Microsoft Power BI Community

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Community Support

Hi, @sb2848

Here are the steps you can refer to :
(1)This is my test data:

(2)We can click "New Column" to  create a calculated column :

``````Flag = var _current_cou='County List'[Country]
var _count =COUNTROWS( FILTER('All Data 2021 & 2022','All Data 2021 & 2022'[County] = _current_cou ))
return
IF(_count >0 ,"Yes" ,"No")``````

(3)The result is as follows:

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Best Regards,

Aniya Zhang

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

3 REPLIES 3
Regular Visitor

I tried a different approach converting the below excel formula into DAX, I tried a different approach, but I am not getting the right output. Hoping you can point me in the right direction.

=IF(COUNTIF('County List'!A:A,[@County])>0,"Yes", "No")

my approach

County  = CALCULATE(COUNT('County List'[County] >0, FILTER('All Data 2021 & 2022', 'All Data 2021 & 2022'[County] = "Yes" || 'All Data 2021 & 2022' [County] = "No"))

Community Support

Hi, @sb2848

Here are the steps you can refer to :
(1)This is my test data:

(2)We can click "New Column" to  create a calculated column :

``````Flag = var _current_cou='County List'[Country]
var _count =COUNTROWS( FILTER('All Data 2021 & 2022','All Data 2021 & 2022'[County] = _current_cou ))
return
IF(_count >0 ,"Yes" ,"No")``````

(3)The result is as follows:

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

Best Regards,

Aniya Zhang

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

Super User

@sb2848 COUNTIF is COUNTX(FILTER(...),...) in DAX. CO-CU Excel to DAX Translation - Microsoft Power BI Community

Become an expert!: Enterprise DNA
External Tools: MSHGQM
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Announcements

#### 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

#### Fabric Community Update - April 2024

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

#### Power BI Monthly Update - March 2024

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

Top Solution Authors
Top Kudoed Authors