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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
uniqum47
Frequent Visitor

count of certain values per group

Hi, it sounds like such a simple problem, but I am stuck with it and tried several solutions offered on the forum with no luck.

I have following DevOps data  of related  parent and children in one table (yeah not the best, but decided to leave it in one table since data is not heavy). It is one to many relaitonships between 1 source to many targets. 

I need a measure that will give me how much state Value (closed) is per each Source Item (i.e.  for source #1 Closed = 1, for source #2  - o, per #3 - 2.

At the end, I need it to calculate the % of closed children under each parent, which I can do (using countr of children)once figure out the measure per state. 

Your help is Very much appreciated

 

SourceWorkItemIDStateTargetWorkItemIDCount of Children
1New113
1Closed123
1Active133
2New212
2New222
3Closed332
3Closed322

 

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@uniqum47 

I made a measure to calculate the %, it will work at the total level as well.

% closed Children = 
var __Closed = 
    SUMX(
        VALUES(Table2[SourceWorkItemID]),
        CALCULATE(
            COUNT(Table2[State]),
            Table2[State] = "Closed"
        )
    )
var __Count = 
    SUMX(
        VALUES(Table2[SourceWorkItemID]),
        CALCULATE( COUNT(Table2[State]) )
    )
var __result = 
    DIVIDE( __Closed , __Count )
return
    __result

Fowmy_0-1626180846526.png

 



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@uniqum47 

I made a measure to calculate the %, it will work at the total level as well.

% closed Children = 
var __Closed = 
    SUMX(
        VALUES(Table2[SourceWorkItemID]),
        CALCULATE(
            COUNT(Table2[State]),
            Table2[State] = "Closed"
        )
    )
var __Count = 
    SUMX(
        VALUES(Table2[SourceWorkItemID]),
        CALCULATE( COUNT(Table2[State]) )
    )
var __result = 
    DIVIDE( __Closed , __Count )
return
    __result

Fowmy_0-1626180846526.png

 



 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

thank you  - that helped a lot.

Can I stretch my luck and ask for further help - the requirement has changed  -if items are Closed, they are not necessarily released to prod. I have another column with release date mixed with null, I transfered it to 1 - not released, 2 released.

I tried to adjust your query, but it doesnt adjust to count all children with 1 and 2. I need it to group, then count how many 2 are in the group anf give me % of 2 per group (i.e. group 2 is 50%).

I feel like I am missing something basic 😞

Many many thanks!

 

 

 

SourceWorkItemIDStateTargetWorkItemIDCount of Childrenrelease
1New1131
1Closed1232
1Active1332
2New2122
2New2221
3Closed3321
3Closed3222

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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