Get Epic Name through subtasks

I have the following structure in Jira:

Epic → Task → Subtask

I need to have a column that shows the “Epic name” of the Epico, the task and the subtasks, for the Epics and Tasks I got it through the Epic Link, but for the subtasks that are inside the tasks I don’t know how to do it because it’s a level too much and subtasks do not have Epic Link.
I am currently using the following code:

CASE WHEN [Measures].[Issue type] = “Epic”
THEN --for epics return Epic Name
CoalesceEmpty([Measures].[Issue Epic Name],"")
ELSE – for other issues return linked Epic Name
[Issue].[Issue].GetMemberByKey(
[Measures].[Issue Epic Link]
).Get(‘Epic Name’)
END

Would anyone know how to increment this rule to get the “Epic Name” through subtasks too?

@Douglas

Try this formula for your calculated measure:

Try this formula for “Projeto” measure:

CASE WHEN [Measures].[Issue type] = "Epic"
THEN --for epics return Epic Name
  CoalesceEmpty([Measures].[Issue Epic Name],"")
  
  WHEN
  [Measures].[Issue type] = "Sub-task"
  THEN
  [Issue].[Issue].GetMemberByKey  
  (
    [Issue.Sub-task].[Sub-task].GetMemberByKey(
    [Issue].CurrentMember.key
  ).Parent.get('Epic Link')
  ).get('Epic Name')
ELSE -- for other issues return linked Epic Name
  [Issue].[Issue].GetMemberByKey(
    [Measures].[Issue Epic Link]
  ).Get('Epic Name')
END

Martins / eazyBI support