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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Anonymous
Not applicable

Counting the number of occurences of a field

Hi Everyone,

 

I would really appreciate anyones help with my situation.

 

Below is a table im working on

 

I am trying to count how many 'trues' and 'falses' there are for each CP_ID. I then want to find the percentage of 'trues' from the total of both 'trues' and 'falses'. 

 

I have tried this but get an error explaining I cant count boolean values.

 

NumberHits = CALCULATE(COUNT(name[WIN_FLAG]), name[WIN_FLAG]=TRUE(),ALL(name[WIN_FLAG]))
 
Any help would be appreciated.

 

 

bi help.png

1 ACCEPTED SOLUTION

Try

 

NumberHits = CALCULATE(COUNT(name[CP_ID]), name[WIN_FLAG]=TRUE())
NumberMisses = CALCULATE(COUNT(name[CP_ID]), name[WIN_FLAG]=FALSE())
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

You can count CP_ID if both do not have any null values (nonoverlapping).

 

 

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Good idea, Counting the CP will give me the total of both true and false. How can I then split this and find the number for each true and false?

Try

 

NumberHits = CALCULATE(COUNT(name[CP_ID]), name[WIN_FLAG]=TRUE())
NumberMisses = CALCULATE(COUNT(name[CP_ID]), name[WIN_FLAG]=FALSE())
Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

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

Top Kudoed Authors