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

View all the Fabric Data Days sessions on demand. View schedule

Reply
TomSinAA
Helper IV
Helper IV

Measure to group and count rows

I have data that is structured like this: 

M-IDS-IDEnteredBy
M-1S1C
M-1S2C
M-1S3C
M-1S4C
M-2S1C
M-2S2D
M-2S3NE
M-3S1C
M-3S2D
M-3S3D
M-3S4D
M-3S5D
M-3S6

D

 

I have a measure that provides a grouping by enteredby value: Entered By Group = If(ISBLANK(Table1[Entered]),"Not Entered", If(Find("D",TMSShipmentDetail[EnteredBy],1,99)<>99,"D-group,"C-group"))

 

I would like to add another measure to count at the M-ID level. So I can get a count showing all S-IDs entered by C or not all S-IDs entered by C.  So for the example data above the table would look like this: 

Count of M-IDsGrouping
1All S-ID entered by C-group
2Not All S-IDs entered by C Group
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @TomSinAA ,

 

First create an enter table:

vcgaomsft_0-1727057604825.png

Then please create this measure:

Count of M-IDs = 
VAR __table = SUMMARIZE('Table1','Table1'[M-ID],'Table1'[S-ID],"@EnteredBy",[Entered By Group])
VAR __c_sid = CALCULATETABLE(VALUES(Table1[S-ID]),FILTER(__table,[@EnteredBy]="C"))
VAR __not_c_sid = CALCULATETABLE(VALUES(Table1[S-ID]),FILTER(__table,[@EnteredBy]<>"C"))
VAR __only_c_count = COUNTROWS(EXCEPT(__c_sid,__not_c_sid))
VAR __not_only_c_count = COUNTROWS(EXCEPT(__not_c_sid,__c_sid))
VAR __result = IF(SELECTEDVALUE('Table'[Grouping])="All S-ID entered by C-group",__only_c_count,__not_only_c_count)
RETURN
__result

Output:

vcgaomsft_1-1727057659204.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Hi @TomSinAA ,

 

First create an enter table:

vcgaomsft_0-1727057604825.png

Then please create this measure:

Count of M-IDs = 
VAR __table = SUMMARIZE('Table1','Table1'[M-ID],'Table1'[S-ID],"@EnteredBy",[Entered By Group])
VAR __c_sid = CALCULATETABLE(VALUES(Table1[S-ID]),FILTER(__table,[@EnteredBy]="C"))
VAR __not_c_sid = CALCULATETABLE(VALUES(Table1[S-ID]),FILTER(__table,[@EnteredBy]<>"C"))
VAR __only_c_count = COUNTROWS(EXCEPT(__c_sid,__not_c_sid))
VAR __not_only_c_count = COUNTROWS(EXCEPT(__not_c_sid,__c_sid))
VAR __result = IF(SELECTEDVALUE('Table'[Grouping])="All S-ID entered by C-group",__only_c_count,__not_only_c_count)
RETURN
__result

Output:

vcgaomsft_1-1727057659204.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum 

parry2k
Super User
Super User

@TomSinAA you are looking for dynamic segmentations, there are many solutions to this, check out one blog post here and this will get you started.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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
Top Kudoed Authors