Not working - Need to create a Calculated Field in Measures to filter out Sub Tasks based on condition

Hi,

I have to create a calculated field in the Measure section to count all the Sub tasks that satisfy the conditions as mentioned in the below JQL.

project = OPS
AND issuetype = Sub-task
AND (labels IS EMPTY OR labels NOT IN (data-validation, InvalidSheetNames, InvalidSheetStatusValue, InvalidSheetsMapping, FileUnlockError, FileExtensionError, NoWorksheetsLoadedError))
AND labels NOT IN (Unidentified_repository_ID, MissingWorksheetsError)
AND (fixVersion in unreleasedVersions() OR fixVersion is EMPTY)
ORDER BY Rank ASC

So I created the field with the below code but it’s giving 0 as results as opposed to the above query that is giving a different count (625). Can someone help and suggest the possible fix for this?

CASE WHEN
  [Issue].CurrentHierarchyMember.Level.Name = "Sub-task" AND
  [Project].CurrentMember.Name = "OPS" AND
  (
    IsEmpty([Label].CurrentMember.Name) OR
    (
      [Label].CurrentMember.Name <> "data-validation" AND
      [Label].CurrentMember.Name <> "InvalidSheetNames" AND
      [Label].CurrentMember.Name <> "InvalidSheetStatusValue" AND
      [Label].CurrentMember.Name <> "InvalidSheetsMapping" AND
      [Label].CurrentMember.Name <> "FileUnlockError" AND
      [Label].CurrentMember.Name <> "FileExtensionError" AND
      [Label].CurrentMember.Name <> "NoWorksheetsLoadedError"
    )
  ) AND
  [Label].CurrentMember.Name <> "Unidentified_repository_ID" AND
  [Label].CurrentMember.Name <> "MissingWorksheetsError" AND
  (
    [Fix Version].CurrentMember.GetBoolean("Unreleased") OR
    IsEmpty([Fix Version].CurrentMember.Name)
  )
THEN
  1
ELSE
  0
END

Hi @vibhutiverma,

Labels are multi-selection fields, and filtering issues without specific labels might give false results as the issue might have some other label that is allowed. When eazyBI checks on a label (or any other multi-value field), each label (value) is considered independently from other labels (values) assigned to the issue.

The best approach would be to create a JavaScipr calculated field that sorts issues by valid and invalid labels during data import. See the documentation for more details on how to create JavaScript calculated fields for an eazyBI account: Account specific calculated fields

The JavaScript code for grouping issues by labels might look like this:

// get the labels array from the issue fields
const labels = issue.fields.labels || [];
// list the target labels you are looking for
const targetLabels = ['data-validation','InvalidSheetNames','InvalidSheetStatusValue','InvalidSheetsMapping','FileUnlockError','FileExtensionError','NoWorksheetsLoadedError','Unidentified_repository_ID','MissingWorksheetsError'];

// check if any labels assigned
if (labels.length === 0) {
  return "invalid labels";
}

// Check if any of the issue's labels match the target labels
if ( labels.some(label => targetLabels.includes(label)) ) {
  return "invalid labels";
}
else {
  return "valid labels"
}

The field configuration as in picture below

While creating the calauted field, validate it on individual issues to see if it gives expected resuls or it requires any adjustments. You can use AI assistant to help modifying the code (AI assistants are avaialbel on Cloud)

When you have a imported the new dimension to group issue by labels, you can use a tuple expressions to see issues in one or another group of labels (see documentation for more details: Calculated measures)

See related community posts on how to filter data by labels:

Best,
Zane / support@eazyBI.com