cancel
Showing results for 
Search instead for 
Did you mean: 
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
v-eqin-msft
Community Support
Community Support

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
v-eqin-msft
Community Support
Community Support

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])

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
Join Arun Ulag at MPPC23

Join Arun Ulag at MPPC23

Get a sneak peek into this year's Power Platform Conference Keynote.

PBI Sept Update Carousel

Power BI September 2023 Update

Take a look at the September 2023 Power BI update to learn more.

Learn Live

Learn Live: Event Series

Join Microsoft Reactor and learn from developers.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Top Solution Authors