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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
hyggins
Helper I
Helper I

How to create COUNT() measure based on multiple criteria?

I have the following tables:

Customers – list of customers

Customer States – many to many relationships of customers and operating states

Customer Categories – many to many relationships of customers and operating categories

Customer Options – list of options available to customers by State and Category combination

 

Tables.png

I need a measure that will count options by customer id based on their states and categories

See sample output with matching IDs for reference

 

Output.png

How do I create/design the relationships to facilitate such a measure?

What would the actual measure code look like?

 

Thank you!

1 ACCEPTED SOLUTION

Hi @hyggins ,

 

You could merge these tables with "Inner Join" to get a new table "Merge1".

Then use the following measures to get result.

 

Count =
CALCULATE (
    COUNT ( Merge1[Customer Category Id] ),
    ALLEXCEPT ( Merge1, Merge1[Customer Id] )
)
Option Ids =
CONCATENATEX ( Merge1, Merge1[Option Id], "," )

 

Here is the result.

1-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

View solution in original post

5 REPLIES 5
v-eachen-msft
Community Support
Community Support

Hi @hyggins ,

 

I still don't understand your expected result.

For example, Customer 1 have 2 states : NY & CA, 1 category : A. So I get 101,106,109,110. It is different from your result which you just keep NY. So, do you have any other relationships not mentioned?

3-1.PNG

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Hello @v-eachen-msft ,

 

It seems you understand my data better than I do. My apologies for the incorrect results table. See below for update.

 

Count of Custom Options Results
CustomerCountOption Ids
14101, 106, 109, 110
26102, 103, 106, 109, 112, 113
32108, 111
47101, 104, 105, 106, 107, 109, 110

 

Regarding additional relationships, I do have an OptionsDim and CategoriesDim but didn't think that factored in.

 

I'm also reposting the table at @Greg_Deckler 's request.

Customers
Customer Id
1
2
3
4

 

Customer States
Customer IdCustomer State Id
1NY
1CA
2GA
2KY
2CA
3TX
4WI
4NY
4CA

 

Customer Categories
Customer IdCustomer Category Id
1A
2A
2B
3B
4A
4C

 

Customer Options
Option IdState IdCategory Id
101NYA
102CAB
103GAA
104NYC
105WIA
106CAA
107NYC
108TXB
109CAA
110NYA
111TXB
112GAB
113KYA

 

Thank you!

Hi @hyggins ,

 

You could merge these tables with "Inner Join" to get a new table "Merge1".

Then use the following measures to get result.

 

Count =
CALCULATE (
    COUNT ( Merge1[Customer Category Id] ),
    ALLEXCEPT ( Merge1, Merge1[Customer Id] )
)
Option Ids =
CONCATENATEX ( Merge1, Merge1[Option Id], "," )

 

Here is the result.

1-1.PNG

Here is my test file for your reference.

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.

Hello @v-eachen-msft 

 

Thank you so much for your suggestions!

 

Your ideas lead me to the result I was looking for. I appreciate your time!

 

 

Greg_Deckler
Community Champion
Community Champion

Can you post the data as text so we do not have to type it all in by hande?

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

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.