We follow SAFe agile where our internal organization of JIRA is as below
Objectives
|- EPICs
|- Tasks/Story
Every EPIC is associated with an Objective under the Features section.
Query used: project in (PROJECTID) and ("SAFe PI" in ("PI 13")) and ((issuetype in (Objective)) OR (issuetype in (Epic) and issueLinkType not in ("is contained in"))) order by key asc
Then in Structure, I group by Objectives to list the corresponding EPIC under it. Also to list any other EPICs which aren't part of Objectives.
Due to some reason if the EPIC work isn't accomplished it would be included in the new Objective in the next PI. The current JQL would not fetch the EPICs which were part of the previous PI, also no easy way to check if there are any EPICs that aren't part of the current PI Objectives.