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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Count Rows with conditions

Hello,

I have the following data

IDOpportunity NameAmountStageActivity_IDActivity_Status
1Opp1450Open1Completed
1Opp1450Open2Open
2Opp2550Open3Completed
2Opp2550Open4Completed
3Opp3320Closed Won5Completed
4Opp4230Closed Won6Completed
5Opp5780Closed Won7Completed
6OPP6980Open8Completed
6OPP6980Open9Completed
7OPP7760Open  
8OPP8345Open  
9Opp9657Closed Won10Completed
10OPP10879Open11Open
11OPP11687Open12Completed
12OPP124678Open13Completed
13OPP131500Open14Open
14Opp143400Closed Won15Completed
15Opp154388Closed Lost16Completed
16Opp163400Closed Lost17Completed
17OPP179000Open18Open
18OPP184000Open19Open
19OPP193000Open20Open
20Opp201000Closed Won21Completed

 

I need to calculate the number of Opportunitites that are still in stage "open" but either do not have any related activity or their related activities are "completed" and they do not have any further open activities

 

please support

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

According to my understanding, you want to count rows when

1.the Stage is Openand

2.the Acticity_ID is blank or the Activity_Status is Open , right?

 

You could use the following formula:

 

Column =
IF (
    'Opp'[Stage] = "Open"
        && (
            ISBLANK ( [Activity_ID] )
                || Opp[Activity_Status] = "Open"
        ),
    1,
    0
)
count =
CALCULATE ( COUNTROWS ( 'Opp' ), FILTER ( ALL ( 'Opp' ), [Column] = 1 ) )

 

My visualization looks like this:

8.26.6.1.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

 

Best Regards,

Eyelyn Qin

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Anonymous ,

According to my understanding, you want to count rows when

1.the Stage is Openand

2.the Acticity_ID is blank or the Activity_Status is Open , right?

 

You could use the following formula:

 

Column =
IF (
    'Opp'[Stage] = "Open"
        && (
            ISBLANK ( [Activity_ID] )
                || Opp[Activity_Status] = "Open"
        ),
    1,
    0
)
count =
CALCULATE ( COUNTROWS ( 'Opp' ), FILTER ( ALL ( 'Opp' ), [Column] = 1 ) )

 

My visualization looks like this:

8.26.6.1.png

Did I answer your question ? Please mark my reply as solution. Thank you very much.

If not, please upload some insensitive data samples and expected output.

 

Best Regards,

Eyelyn Qin

 

Best Regards,

Eyelyn Qin

Anonymous
Not applicable

Hello,

the resuklt is not correct as it should read 6 and not 8.

Opportunity 1 is included while it should not as it has already an open activity.

and we should not count more than one the same opportunity.

 

thank you

 

regards,

Imbrg

amitchandak
Super User
Super User

@Anonymous , try like


countx(filter(summarize(filter(Table, table[status] ="Open"), table[ID],"_1", calculate(count(table[ID]), isblank(table[Activity_Status]) || table[Activity_Status] ="completed")+0),[_1] =0),[ID])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hello

I tried the measure but it's giving me the following error ; too few arguments were passed to filter function. the minimum arguments count for the fucntion is 2

 

please support

 

regards,

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.