diff --git a/public/app/features/dimensions/utils.ts b/public/app/features/dimensions/utils.ts index 983356ab430..139386dc914 100644 --- a/public/app/features/dimensions/utils.ts +++ b/public/app/features/dimensions/utils.ts @@ -91,20 +91,8 @@ export function getTextDimensionFromData( } export function findField(frame?: DataFrame, name?: string): Field | undefined { - if (!frame || !name?.length) { - return undefined; - } - - for (const field of frame.fields) { - if (name === field.name) { - return field; - } - const disp = getFieldDisplayName(field, frame); - if (name === disp) { - return field; - } - } - return undefined; + const idx = findFieldIndex(frame, name); + return idx == null ? undefined : frame!.fields[idx]; } export function findFieldIndex(frame?: DataFrame, name?: string): number | undefined {