Feature to User Stories to Bugs & Test Cases

I am working on a report where I need to display Features row wise along with the count of associated Stories followed by the sum of Bugs and Test Cases (TestXY) linked to each of the associated Stories.

I have already defined two Calculated Custom Fields in Advanced Settings -

  1. User Story Defect Count > This calculates the number of Defects associated with a User Story
  2. User Story Test Case Count > This calculates the number of Defects associated with a User Story

I am able to display the Stories row wise along with User Story Defect Count and User Story Test Case Count as below.

However, I am unable to tie these to the Feature. All User Stories have the Feature Link populated. Can you please help me here?

Thanks,
Ranjan

Here is the screenshot of the Feature which is NOT working.

I have been able to solve this. I defined the below calculated measure to roll up the defects associated with each User Story.

CoalesceEmpty(
CASE WHEN
(
[Measures].[Issues created],
[Issue Type].[Story]
) > 0
THEN
SUM(
Filter(
Descendants([Issue].CurrentMember, [Issue].[Issue]),
[Measures].[Issue type]= “Story” AND
[Measures].[Issues created] > 0
),
[Measures].[Issue Defect Count]
)
END,
0
)

Below is the screenshot of the report.