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
vanessafvg
Super User
Super User

calculated column = count values? (sum if)

i need to  created a calcualted column that counts the columns where the value is yes

 

ie

 

column1   column2  column3   column4   calculatedcolumn

yes                            yes            yes             3

 

 

what would be the best way to create this?





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




1 ACCEPTED SOLUTION

Hi @vanessafvg,

 

The solution provided by @AndrejZitnay is on the Query editor however if you want to do it in DAX you should use the following formula:

 

Count of Yes = IF(Table2[1] = "yes";1;0) + IF(Table2[2] = "yes";1;0) + IF(Table2[3] = "yes";1;0) + IF(Table2[4] = "yes";1;0)

Some principal different syntax.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

6 REPLIES 6
AndrejZitnay
Post Patron
Post Patron

Hello @vanessafvg

 

I would maybe to some measurment but if you want that in colum than :

 

step 1

add 4 conditional columns and if operator equal yes than 1 otherwise 0

 

step 2

add all 4 conditional columns together.

sample.png

 

@AndrejZitnay hi that is actually a good idea but a calculate column seems less complex if i can get the logic right





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi @vanessafvg,

 

The solution provided by @AndrejZitnay is on the Query editor however if you want to do it in DAX you should use the following formula:

 

Count of Yes = IF(Table2[1] = "yes";1;0) + IF(Table2[2] = "yes";1;0) + IF(Table2[3] = "yes";1;0) + IF(Table2[4] = "yes";1;0)

Some principal different syntax.

 

Regards,

MFelix


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



@MFelix yep go it thanks





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Hi @vanessafvg and @AndrejZitnay,

 

Although the option from @AndrejZitnay is correct you can make it just with one column:

(if [1] = "Yes" then 1 else 0) +
(if [2] = "Yes" then 1 else 0) +
(if [3] = "Yes" then 1 else 0) +
(if [4] = "Yes" then 1 else 0)

Regards,

MFelix

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



AndrejZitnay
Post Patron
Post Patron

Hello @vanessafvg

 

I would maybe to some measurment but if you want that in colum than :

 

step 1

add 4 conditional columns and if operator equal yes than 1 otherwise 0

 

step 2

add all 4 conditional columns together.

sample.png

 

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!

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.