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 number of rows where filter is 1

Hello All,

 

Could you please help to calculate number of rows where filter is 1? I've put this formula but there are wrong calculation:

 

Count lines undeliv = CALCULATE(COUNTROWS(CDP_data);FILTER('CDP_data';'CDP_data'[Negative))
 
Many thanks for your help.
6 REPLIES 6
AlB
Super User
Super User

Hi @Anonymous 

How do you tell it's not delivered? CAn you show a sample of your table?Try something like this  

Count lines undeliv =
CALCULATE (
    COUNTROWS ( CDP_data );
    FILTER ( 'CDP_data'; 'CDP_data'[Undelivered] = 1 )
)
Anonymous
Not applicable

Hi @AlB not delivered i've counted like that:  Negative = if(CDP_data[Undelivered]<0;1;0)

 

Ok, so then this should work, as a measure in a card visual. If it doesn't, please share a sample of your tables or the pbix:

Count lines undeliv =
CALCULATE (
    COUNTROWS ( CDP_data );
    FILTER ( 'CDP_data'; 'CDP_data'[Undelivered] < 0  )
)

 

Anonymous
Not applicable

@AlB It's working but calculcation is wrong.

I have columnt oredered, delivered, undelivered which is calculated: 

Undelivered = if(CDP_data[Delivered qty]<=CDP_data[Ordered qty];CDP_data[Delivered qty]-CDP_data[Ordered qty];0)+0
And after negative:  Negative = if(CDP_data[Undelivered]<0;1;0)
And I need to know hom many negative (1) lines are in total. 

 

 

 mistake_negative.JPG

Hi @Anonymous ,

Create a measure as below.

countrows =  CALCULATE (
    COUNTROWS ( CDP_data );
    FILTER ( 'CDP_data'; 'CDP_data'[Negative] =1  )
)
Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

@v-frfei-msft still the same mistake when I have =1, but it counts correctly when i choose =0. 

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.