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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

DAX Query

Hi, 
I have 1 Question Related to Power Query 

rubikajadhav123_0-1647072770006.png

This is my Table from Column A to E and I need to calculate it in DAX
I know How to calculate it in Excel but not in Dax 
In Excel, we can use Count if Function but in DAX it looks like a Trickey 

1 ACCEPTED SOLUTION
tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

You are right, that this is not as trivial as in Excel. Normally you would need to do some unpivoting on your table to get your result as explained here:

Solved: Power Query - count across columns if condition me... - Microsoft Power BI Community

 

However, a quick and dirty solution could be something like this:

tomfox_0-1647076313811.png

Here the code:

TomsNewCountColumn = 
IF ( 'Table12'[A] = TRUE, 1, 0) + 
IF ( 'Table12'[B] = TRUE, 1, 0) + 
IF ( 'Table12'[C] = TRUE, 1, 0) + 
IF ( 'Table12'[D] = TRUE, 1, 0) + 
IF ( 'Table12'[E] = TRUE, 1, 0)

Be aware though that this is not scalable and I would always go for some proper changes on your table before applying the code above. However, since your query was to count all trues accross columns, it might still work for you 🙂

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

View solution in original post

2 REPLIES 2
CNENFRNL
Community Champion
Community Champion

Use PQ,

CNENFRNL_0-1647078878619.png


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

tackytechtom
Most Valuable Professional
Most Valuable Professional

Hi @Anonymous ,

 

You are right, that this is not as trivial as in Excel. Normally you would need to do some unpivoting on your table to get your result as explained here:

Solved: Power Query - count across columns if condition me... - Microsoft Power BI Community

 

However, a quick and dirty solution could be something like this:

tomfox_0-1647076313811.png

Here the code:

TomsNewCountColumn = 
IF ( 'Table12'[A] = TRUE, 1, 0) + 
IF ( 'Table12'[B] = TRUE, 1, 0) + 
IF ( 'Table12'[C] = TRUE, 1, 0) + 
IF ( 'Table12'[D] = TRUE, 1, 0) + 
IF ( 'Table12'[E] = TRUE, 1, 0)

Be aware though that this is not scalable and I would always go for some proper changes on your table before applying the code above. However, since your query was to count all trues accross columns, it might still work for you 🙂

/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/



Did I answer your question➡️ Please, mark my post as a solution ✔️

Also happily accepting Kudos 🙂

Feel free to connect with me on LinkedIn! linkedIn

#proudtobeasuperuser 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.