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
Anonymous
Not applicable

How to count number of clients that have 2 items in a specific order

Hello community members, 

 

I have to following issue: 

 

I would like to know the number of clients that 'receive' a Healthcare_Type "A" as well as Healthcare_Type "B" (specific in that particular order; first A, than B). Does anyone know how I should make this measure?

 

Sander84_1-1616691512332.png

 

Hope to hear soon from you. 

 

Best regards, 

 

Sander

1 ACCEPTED SOLUTION
AlexisOlson
Super User
Super User

It's not completely clear how first A then B logic works (e.g. what about ABA or BAB?) but I'll assume taking the first start date of each type is sufficient.

 

A then B Count =
VAR Summary =
    SUMMARIZE (
        Table1,
        Table1[Client_Number],
        "FirstA", CALCULATE ( MIN ( Table1[Start_date] ), Table1[Healthcare_type] = "A" ),
        "FirstB", CALCULATE ( MIN ( Table1[Start_date] ), Table1[Healthcare_type] = "B" )
    )
RETURN
    COUNTROWS (
        FILTER (
            Summary,
            NOT ( ISBLANK ( [FirstA] ) || ISBLANK ( [FirstB] ) )
                && [FirstA] < [FirstB]
        )
    )

 

 

This summarizes, for each client, the first Start_date for type A and type B (returning a summary table with one client per row) and then filters this summary table for clients where neither FirstA nor FirstB is blank and FirstA < FirstB.

View solution in original post

4 REPLIES 4
AlexisOlson
Super User
Super User

It's not completely clear how first A then B logic works (e.g. what about ABA or BAB?) but I'll assume taking the first start date of each type is sufficient.

 

A then B Count =
VAR Summary =
    SUMMARIZE (
        Table1,
        Table1[Client_Number],
        "FirstA", CALCULATE ( MIN ( Table1[Start_date] ), Table1[Healthcare_type] = "A" ),
        "FirstB", CALCULATE ( MIN ( Table1[Start_date] ), Table1[Healthcare_type] = "B" )
    )
RETURN
    COUNTROWS (
        FILTER (
            Summary,
            NOT ( ISBLANK ( [FirstA] ) || ISBLANK ( [FirstB] ) )
                && [FirstA] < [FirstB]
        )
    )

 

 

This summarizes, for each client, the first Start_date for type A and type B (returning a summary table with one client per row) and then filters this summary table for clients where neither FirstA nor FirstB is blank and FirstA < FirstB.

Anonymous
Not applicable

Hi @AlexisOlson, Thank you! This measure works perfect! Cheers, Sander

Jihwan_Kim
Super User
Super User

Hi, @Anonymous 

Please try to use the below calculated measure in a Card Visualization.

 

Card Visualization =
VAR Atype =
CALCULATETABLE (
VALUES ( 'Table'[Client_Number] ),
'Table'[Healthcare_Type] = "A"
)
VAR Btype =
CALCULATETABLE (
VALUES ( 'Table'[Client_Number] ),
'Table'[Healthcare_Type] = "B"
)
RETURN
COUNTROWS ( INTERSECT ( Atype, Btype ) )

 

Did I answer your question? Mark my post as a solution!

Appreciate your Kudos!!


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.
Anonymous
Not applicable

Hi @Jihwan_Kim 

Thanks for your response, but the measure isn't correct... Because the measure also takes the combination First B and Second A (client 1003) and that it not correct...

Cheers, Sander

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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