Skip to main content
cancel
Showing results for 
Search instead 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.

Reply
Anonymous
Not applicable

Count "1" values in a column

Hi All,

 

I've spent far too many hours today trying to figure out what is probably a simple thing for you all...

 

I have a column in PBI that has either 0 or 1 in it for 200+ rows.  I want to count the "1"'s.  I've tried allsorts and been through all of the questions and answers here but they are far more complicated than this.

The column with the 0 and 1 in is "Start 28d" - please help? This would be simple in Excel: countif(range > 0) or something.

 

Thanks,

Martin

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

if the column only has two values,0 and 1, what about use SUM ? The result of SUM is the result of counting 1.





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

Proud to be a Super User!




View solution in original post

8 REPLIES 8
ryan_mayu
Super User
Super User

@Anonymous 

if the column only has two values,0 and 1, what about use SUM ? The result of SUM is the result of counting 1.





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

Proud to be a Super User!




Anonymous
Not applicable

Thanks for this - I should have gotten it, but my mind was set on 'count'.  All working as it should - thank you 🙂

you are welcome





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

Proud to be a Super User!




serpiva64
Super User
Super User

Hi,

try 

Measure = calculate(count('Table'[Column1]),'Table'[Column1]=1)
Anonymous
Not applicable

Thanks! This worked for one of them (start dates) but gives me an error when trying to replicate for finish dates?

 

Finish 28d = IF(Task[Finish Next Period] > -28 && Task[Finish Next Period] < 0, 1, 0)
Finish 28d Qty = CALCULATE ( count (Task[Finish 28d] ),Task[Finish 28d] = 1 )

Start 28d = IF(Task[Start Next Period] > -28 && Task[Start Next Period] < 0, 1, 0)
Start 28d qty = CALCULATE ( COUNT ( Task[Start 28d] ), Task[Start 28d] = 1 )

 

MBCLogik_0-1653585319514.png

 

Hi,

i don't think it's a problem of the measure.

Task[Finish Next Period] or Task[Start Next Period] are calculated columns?

 

Anonymous
Not applicable

Finish Next Period = Task[ReportDate] - Task[Finish]
Start Next Period = Task[ReportDate] - Task[StartDate]
Anonymous
Not applicable

Yes they are calculated.

Helpful resources

Announcements
Microsoft Fabric Learn Together

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

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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