Skip to content

Playground does not multiply by 100 when displaying format: percent values #10623

@hank-sq

Description

@hank-sq

Bug description

The Cube Playground does not multiply values by 100 when displaying measures/dimensions with format: percent. Per the official documentation:

When using the percent format, do not multiply by 100 in your SQL expression. Presentation tools like Explore, Workbooks, and Dashboards apply this multiplication implicitly when displaying percent-formatted values, e.g., a value of 0.5 will be displayed as 50%.

However, the Playground simply appends % to the raw API value without multiplying by 100. A value of 0.273 (representing 27.3%) is displayed as 0.273% instead of 27.3%.

Affected code

The bug exists in three separate rendering paths:

1. QueryBuilderResults.tsx (~line 788)

case 'percent':
  return [
    `${formatNumber(typeof value === 'string' ? parseFloat(value) : value)}%`,
    'percent',
  ];

2. DrilldownModal/TableQueryRenderer.tsx (~line 38)

if (type === 'number' && format === 'percent') {
  return [parseFloat(value).toFixed(2), '%'].join('');
}

3. ChartRenderer.tsx (table chart, ~line 437)

No percent-specific handling at all — raw value is displayed as-is.

Expected behavior

All three paths should multiply the value by 100 before appending %, consistent with the documentation. For example:

case 'percent':
  return [
    `${formatNumber((typeof value === 'string' ? parseFloat(value) : value) * 100)}%`,
    'percent',
  ];

Steps to reproduce

  1. Create a cube with a format: percent measure (e.g., a ratio like 1.0 * {purchases} / {count})
  2. Query it in the Playground
  3. Observe that the value is displayed as e.g. 0.273% instead of 27.3%

Version

Observed on v1.6.30 but appears to be a long-standing issue based on the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions