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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
sanjayjob89
New Member

COUNTIF in DAX

             Column1  Column2

Row1      Yes          Yes

Row 2     Yes          No

 

 

In aformentioned table, I want to create Column3 with count of Yes in Row1 and Row2. How I can i achieve this in DAX?

 

   

1 ACCEPTED SOLUTION

@sanjayjob89 

 

Step1

Coulmn1 Yes Count = IF('Sheet1 (3)'[Coulmn1]="Yes",1,0)
 
Step2
Coulmn2 Yes Count = IF('Sheet1 (3)'[Column2]="Yes",1,0)
 
Step3
Solution = 'Sheet1 (3)'[Coulmn1 Yes Count]+'Sheet1 (3)'[Coulmn2 Yes Count]
 
ribisht17_0-1653132776790.png

 

 

One-Step Solution

Solution=IF('Sheet1 (3)'[Coulmn1]="Yes",1,0)+IF('Sheet1 (3)'[Column2]="Yes",1,0)

Regards,

Ritesh

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users 

View solution in original post

7 REPLIES 7
daXtreme
Solution Sage
Solution Sage

Hi there.

 

This data set does not seem to be suited for analyses in Power BI. Please unpivot it and then everything will be easier.

Whitewater100
Solution Sage
Solution Sage

Hello:

Please see one solution with calc column. My table name is "Table"

Two Yes's = IF(AND('Table'[Column1] = "Yes", 'Table'[Column2] = "Yes"),1,BLANK())
Whitewater100_0-1653064970026.png

 

Actually I want to count number of "Yes" in row1 & row2. For the first row it'll be 2 and second row it'll be 1

OK, you just change to OR

 

Two Yes's = IF(OR('Table'[Column1] = "Yes", 'Table'[Column2] = "Yes"),1,BLANK())
Whitewater100_0-1653068931250.png

 

Even if I change it to OR count of Yes in row1 will be 1 not 2.

Sorry: I misunderstood.

Count Yes's = IF(AND('Table'[Column1] = "Yes", 'Table'[Column2] = "Yes"),2,IF(OR('Table'[Column1] = "Yes", 'Table'[Column2] = "Yes"),1))
Whitewater100_0-1653134104950.png

I hope this is OK now. Thanks..

@sanjayjob89 

 

Step1

Coulmn1 Yes Count = IF('Sheet1 (3)'[Coulmn1]="Yes",1,0)
 
Step2
Coulmn2 Yes Count = IF('Sheet1 (3)'[Column2]="Yes",1,0)
 
Step3
Solution = 'Sheet1 (3)'[Coulmn1 Yes Count]+'Sheet1 (3)'[Coulmn2 Yes Count]
 
ribisht17_0-1653132776790.png

 

 

One-Step Solution

Solution=IF('Sheet1 (3)'[Coulmn1]="Yes",1,0)+IF('Sheet1 (3)'[Column2]="Yes",1,0)

Regards,

Ritesh

Mark my post as a solution if it helped you| Munde and Kudis (Ladies and Gentlemen) I like your Kudos!! !!
My YT Channel Dancing With Data !! Connect on Linkedin !!Power BI for Tableau Users 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.