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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
annade22
New Member

Count values within a groupby and filter

Hi,

 

I hope someone can help me. 

I want to count the Categories per ParentProject and Group if at least one Category = SA. I the ParentProject/Group doesn't include any SA, then I don't want to do anything.

 

My table look like this

ParentProjectProjectIdCategoryGroup
10001000-1SA1
10001000-2MB1
10001000-3PL1
10001000-4RO2
10011001-1SA1
10011001-2RO2
10021002-1SA1
10031003-1MB1
10031003-2PL2
10041004-1SA1
10041004-2MB1
10041004-3PL1

 

My expected result is

ParentProjectNumber of categories
10003
10011
10021
10030
10043

 

I assume I need a groupby, count and filter function but I can't get it right. Appreciate all help

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@annade22 

 

You may add the following measure.

Measure =
COUNTROWS (
    FILTER (
        Table1,
        CONTAINS ( Table1, Table1[Group], Table1[Group], Table1[Category], "SA" )
    )
) + 0
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@annade22 

 

You may add the following measure.

Measure =
COUNTROWS (
    FILTER (
        Table1,
        CONTAINS ( Table1, Table1[Group], Table1[Group], Table1[Category], "SA" )
    )
) + 0
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AlB
Super User
Super User

Hi @annade22 

Try this:

1. Place ParentProject and Group in the rows of a matrix visual. Another option is to place ParentProject only in the visual and Group on a slicer

2.  Create this measure and place it in the visual:

NumCategories =
CALCULATE ( DISTINCTCOUNT ( Table1[Category] ), Table1[Category] <> "SA" )

  

Thankyou, it works to some extent, but I want to filter within a parentproject. The parentprojects that don't have any value of "SA" should be excluded from the formula completely. 

Appreicate your help though!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.