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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
mmartinko
New Member

COUNTROWS - Count NOTBLANK rows across two columns, only count once if both have value

I've tried calculate, groupby, and adding multiple measures, but I'm still not getting the result I need. If both columns have a value I only want to count it as 1. What am I missing?

 

Example: The count result I expect is 3.

 

Data1, Data2

1,blank

blank,1

1,1

blank,blank

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

vicky__0-1688595214254.png

Have you tried something like this: 

measure = COUNTROWS(FILTER('Table', NOT(ISBLANK('Table'[Data1])) || NOT(ISBLANK('Table'[Data2]))))

 

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

You can create a calculated column formula first

Test = 1*and(Data[Data1]<>blank(),Data[Data2]<>blank())

Next, create a measure

Measure = sum(Data[Test])

I have assumed that Data is the name of the Table.

Hope this helps. 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

This looks like it could work, but is only bringing back a value of 1 in the calculated column if both columns are not blank. I need it to account for both not blank, or one or the other.

Hi,

Try this

Test = 1*not(and(Data[Data1]=blank(),Data[Data2]=blank()))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

That did it! Thanks so much.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Nathaniel_C
Community Champion
Community Champion

Hi @mmartinko ,
If I understand your question, please try this:

 

CountOne col = 

Switch (TRUE(),

NOT(ISBLANK(MAX(BlankTable[Column1]))),1,
NOT(ISBLANK(MAX(BlankTable[Column2]))),1

)

 

Nathaniel_C_0-1688595722494.png


Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos 👍are nice too.
Nathaniel

 





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

Proud to be a Super User!




Thanks for the response. This just gives me a total of 1 though.

vicky_
Super User
Super User

vicky__0-1688595214254.png

Have you tried something like this: 

measure = COUNTROWS(FILTER('Table', NOT(ISBLANK('Table'[Data1])) || NOT(ISBLANK('Table'[Data2]))))

 

This appears to have worked as well and doesn't need a calculated column. Thanks!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.