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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors