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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Elisa112
Helper V
Helper V

Count Occurrences based on conditions

Hello

I am trying to count the number meetings in a table based on conditions, here is my data

 

Meeting Table

Cust ID     Meeting ID  Meeting Date    Type           Status     

123           456               1 Jan                 Support      Attended

123           789               1 Feb                Support      Attended 

234           900               1 Jan                 Support     Attended 

788           677                2 Mar               Adhoc       Cancelled

 

Attended Meetings

Cust ID     No. Attended (Support)   No. Attended (Adhoc)

123                     2                                         0

234                     1                                         0

788                    0                                          0

 

The measure I created brings back the same number for all 

 

Count of Support Mtg =
CALCULATE(COUNT(Meetings2[Meeting ID]),FILTER(Meetings2, Meetings2[Type] = "Support Meeting"))
 
All help appreciated, thanks in advance
2 ACCEPTED SOLUTIONS

@Elisa112 Thanks for the clarity. Create two measures as below:

 

Attended (Support) = CALCULATE(COUNT(Meeting[Status]),FILTER(Meeting,Meeting[Status]="Attended" && Meeting[Type]="Support"))+0
 
Attended (Adhoc) = CALCULATE(COUNT(Meeting[Status]),FILTER(Meeting,Meeting[Status]="Attended" && Meeting[Type]="Adhoc"))+0
 

 

 

Tahreem24_0-1734106746537.png

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

Anonymous
Not applicable

Hi, Tahreem24 ,thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.

Hello,@Elisa112 .I am glad to help you.
I tried the measure written by Tahreem24 and the logic of the measure calculation is correct, however there are some small limitations: the external filter conditions are not removed in the filter function, so the data in each row of the table visual also affects the calculation environment of the measure (affected by the current row)
You can see that when only one Cust ID field is placed in the table visual, the measure is calculated correctly, but when more than one field is placed in the table, the calculation environment is affected and the measure is displayed as four rows (instead of the desired aggregation effect below)

vjtianmsft_0-1734319889932.png

My suggestions.

So I've made some small improvements to this, I've added the ALL function to remove all external filters, but of course if you have other slicer filtered fields you can try to use ALLSELECTED() (which ensures that the filtering of the fields in the slicer is passed to the measure)
And added grouping logic to the measure (grouping based on [Cust ID])

vjtianmsft_1-1734319924769.pngvjtianmsft_2-1734319930937.png

If you want to use the slicer to control the result of the calculation of the measure, you can use ALLSELECTED() instead of the ALL() function
like this:

vjtianmsft_4-1734320066906.png

 

This is my measure:

M_Attend_Support = 
VAR _custID =MAX('Meetings2'[Cust ID])
// _custID:Get the Cust ID value for each row
RETURN
CALCULATE (
    COUNT ( 'Meetings2'[Status] ),
    FILTER (
        ALL(Meetings2),
        'Meetings2'[Status] = "Attended"
            && 'Meetings2'[Type] = "Support"
            && 'Meetings2'[Cust ID] = _custID
    )
) + 0




M_Attend_Adhoc = 
VAR _custID =MAX('Meetings2'[Cust ID])
// _custID:Get the Cust ID value for each row
RETURN
CALCULATE (
    COUNT ( 'Meetings2'[Status] ),
    FILTER (
        ALL(Meetings2),
        'Meetings2'[Status] = "Attended"
            && 'Meetings2'[Type] = "Adhoc"
            && 'Meetings2'[Cust ID] = _custID
    )
) + 0

ALLSELECTED function:

M_ALLSELECTED_Attend_Support = 
VAR _custID =MAX('Meetings2'[Cust ID])
// _custID:Get the Cust ID value for each row

RETURN
CALCULATE (
    COUNT ( 'Meetings2'[Status] ),
    FILTER (
        ALLSELECTED(Meetings2),
        'Meetings2'[Status] = "Attended"
            && 'Meetings2'[Type] = "Support"
            && 'Meetings2'[Cust ID] = _custID
    )
) + 0


I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Hi, Tahreem24 ,thanks for your concern about this issue.

Your answer is excellent!
And I would like to share some additional solutions below.

Hello,@Elisa112 .I am glad to help you.
I tried the measure written by Tahreem24 and the logic of the measure calculation is correct, however there are some small limitations: the external filter conditions are not removed in the filter function, so the data in each row of the table visual also affects the calculation environment of the measure (affected by the current row)
You can see that when only one Cust ID field is placed in the table visual, the measure is calculated correctly, but when more than one field is placed in the table, the calculation environment is affected and the measure is displayed as four rows (instead of the desired aggregation effect below)

vjtianmsft_0-1734319889932.png

My suggestions.

So I've made some small improvements to this, I've added the ALL function to remove all external filters, but of course if you have other slicer filtered fields you can try to use ALLSELECTED() (which ensures that the filtering of the fields in the slicer is passed to the measure)
And added grouping logic to the measure (grouping based on [Cust ID])

vjtianmsft_1-1734319924769.pngvjtianmsft_2-1734319930937.png

If you want to use the slicer to control the result of the calculation of the measure, you can use ALLSELECTED() instead of the ALL() function
like this:

vjtianmsft_4-1734320066906.png

 

This is my measure:

M_Attend_Support = 
VAR _custID =MAX('Meetings2'[Cust ID])
// _custID:Get the Cust ID value for each row
RETURN
CALCULATE (
    COUNT ( 'Meetings2'[Status] ),
    FILTER (
        ALL(Meetings2),
        'Meetings2'[Status] = "Attended"
            && 'Meetings2'[Type] = "Support"
            && 'Meetings2'[Cust ID] = _custID
    )
) + 0




M_Attend_Adhoc = 
VAR _custID =MAX('Meetings2'[Cust ID])
// _custID:Get the Cust ID value for each row
RETURN
CALCULATE (
    COUNT ( 'Meetings2'[Status] ),
    FILTER (
        ALL(Meetings2),
        'Meetings2'[Status] = "Attended"
            && 'Meetings2'[Type] = "Adhoc"
            && 'Meetings2'[Cust ID] = _custID
    )
) + 0

ALLSELECTED function:

M_ALLSELECTED_Attend_Support = 
VAR _custID =MAX('Meetings2'[Cust ID])
// _custID:Get the Cust ID value for each row

RETURN
CALCULATE (
    COUNT ( 'Meetings2'[Status] ),
    FILTER (
        ALLSELECTED(Meetings2),
        'Meetings2'[Status] = "Attended"
            && 'Meetings2'[Type] = "Support"
            && 'Meetings2'[Cust ID] = _custID
    )
) + 0


I hope my suggestions give you good ideas, if you have any more questions, please clarify in a follow-up reply.
Best Regards,
Carson Jian

Thanks for your assistance on this, I actually used the following which I found from a previous thread, the main difference is I created a calcuated column, although I believe a measure is more dynamic:

Count Support Mtg Attended = COUNTROWS(FILTER(Meetings, Meetings[Cust ID] = EARLIER('Meetings'[Cust ID]) && 'Meetings'[Type] = "Support" && 'Meetings'[Status] = "Attended"
))
 
Thank you
Tahreem24
Super User
Super User

@Elisa112 ,Please share the expected output  also.

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Apologies, this the expected output

 

Attended Meetings

Cust ID     No. Attended (Support)   No. Attended (Adhoc)

123                     2                                         0

234                     1                                         0

788                     0                                          0

 

Thanks

 

@Elisa112 Thanks for the clarity. Create two measures as below:

 

Attended (Support) = CALCULATE(COUNT(Meeting[Status]),FILTER(Meeting,Meeting[Status]="Attended" && Meeting[Type]="Support"))+0
 
Attended (Adhoc) = CALCULATE(COUNT(Meeting[Status]),FILTER(Meeting,Meeting[Status]="Attended" && Meeting[Type]="Adhoc"))+0
 

 

 

Tahreem24_0-1734106746537.png

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Thank you, I did use your solution in part but in the end I used a calculated column. but I appreciate your time 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors