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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Creating self join in a Measure to count the child rows

I have the following table structure

 

Key      IssueType      Parent      Status

K001    EPIC

K002    EPIC

K003    Task                K001       Open

K004    Task                K002       Closed

K005    Task                K001       Open

K006    Bug                 K002       Open

 

I am trying to:

  1. count the total number of child (Task+Bugs) of each EPIC
  2. Count the total number of "Closed" child of each EPIC

I was able to do it as a COLUMN using the EARLIER  DAX method but I am unable to use the same in a MEASURE.

Any help or guidance is appreciated.

 

 

 

 

1 ACCEPTED SOLUTION
Icey
Community Support
Community Support

Hi @Anonymous ,

You can create your measures like so:

IF (
    MAX ( 'Table'[Parent] ) <> BLANK (),
    CALCULATE (
        COUNT ( 'Table'[Key] ) + 0,
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[Parent] ), 'Table'[IssueType] <> "EPIC" )
    )
)
total number of "Closed" child of each EPIC =
IF (
    MAX ( 'Table'[Parent] ) <> BLANK (),
    CALCULATE (
        COUNT ( 'Table'[Key] ) + 0,
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[Parent] ), 'Table'[Status] = "Closed" )
    )
)

Creating self join in a Measure to count the child rows 2.PNG

Best Regards,

Icey

 

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
Icey
Community Support
Community Support

Hi @Anonymous ,
 
Is this problem sloved?
 
If it is sloved, could you kindly accept it as a solution to close this case?  
 
If not, please let me know.  
 
Best Regards
Icey
Icey
Community Support
Community Support

Hi @Anonymous ,

You can create your measures like so:

IF (
    MAX ( 'Table'[Parent] ) <> BLANK (),
    CALCULATE (
        COUNT ( 'Table'[Key] ) + 0,
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[Parent] ), 'Table'[IssueType] <> "EPIC" )
    )
)
total number of "Closed" child of each EPIC =
IF (
    MAX ( 'Table'[Parent] ) <> BLANK (),
    CALCULATE (
        COUNT ( 'Table'[Key] ) + 0,
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[Parent] ), 'Table'[Status] = "Closed" )
    )
)

Creating self join in a Measure to count the child rows 2.PNG

Best Regards,

Icey

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thanks Icey,
Really appreciate your help on this one.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.