iOfficeAI/OfficeCLI · error · ArgumentException

showDataAs '{showAs}' is not yet supported by the renderer (

Error message

showDataAs '{showAs}' is not yet supported by the renderer (would silently return raw aggregate). Supported: normal, percent_of_total, percent_of_row, percent_of_col, running_total.

What it means

ParseShowDataAs accepts difference / diff / percent_diff / percentdiff / index tokens but immediately throws, because while the OOXML ShowDataAsValues enum defines them, the in-process renderer (ApplyShowDataAs1x1) has no matrix transformation for them — accepting them would silently render the raw aggregate and mislead the user. The message names the supported set so the user can pick a working alternative.

Source

Thrown at src/officecli/Core/PivotTableHelper.Parse.cs:458

    }

    private static ShowDataAsValues? ParseShowDataAs(string showAs)
    {
        return showAs.ToLowerInvariant() switch
        {
            "" or "normal" => null,
            "percent_of_total" or "percentoftotal" or "percent" => ShowDataAsValues.PercentOfTotal,
            "percent_of_row" or "percentofrow" => ShowDataAsValues.PercentOfRaw,
            "percent_of_col" or "percent_of_column" or "percentofcol" or "percentofcolumn" => ShowDataAsValues.PercentOfColumn,
            "running_total" or "runningtotal" or "runtotal" => ShowDataAsValues.RunTotal,
            // CONSISTENCY(strict-enums): difference / percent_diff / index are
            // accepted by the OOXML ShowDataAsValues enum, but ApplyShowDataAs1x1
            // has no matrix transformation for them, so rendered cells would
            // silently equal the raw aggregate. Reject up front until a proper
            // renderer exists, mirroring the invalid-sort / invalid-aggregate
            // policy from Round 1.
            "difference" or "diff" or "percent_diff" or "percentdiff" or "index" =>
                throw new ArgumentException(
                    $"showDataAs '{showAs}' is not yet supported by the renderer " +
                    "(would silently return raw aggregate). Supported: normal, " +
                    "percent_of_total, percent_of_row, percent_of_col, running_total."),
            // CONSISTENCY(strict-enums): unknown showAs tokens are rejected
            // up front so users see typos at Add/Set time, not on render.
            _ => throw new ArgumentException(
                $"invalid showDataAs: '{showAs}'. Valid: normal, percent_of_total, percent_of_row, " +
                "percent_of_col, running_total"),
        };
    }

    // R11-2: Right-to-left value-spec parser support. Token recognizers
    // mirror the cases ParseSubtotal / ParseShowDataAs accept (lowercase
    // canonical only — we lowercase the token before calling). Keep these
    // in sync if new aggregates / showAs tokens are added downstream.
    private static bool IsKnownAggregateToken(string token) => token switch
    {
        "sum" or "count" or "countnums" or "countnum" or "average" or "avg" or

View on GitHub (pinned to 1ced45e900)

Solutions

  1. Use a supported showAs: normal, percent_of_total, percent_of_row, percent_of_col, or running_total
  2. Compute the difference/percent_diff transform upstream and feed the resulting values as a regular sum field
  3. Track the feature request — these tokens are deliberately gated until a proper renderer exists

Example fix

// before
values="Sales:sum:percent_diff"
// after (compute upstream, or pick a supported showAs)
values="Sales:sum:percent_of_total"
Defensive patterns

Strategy: validation

Validate before calling

var unsupported = new[] { "difference", "diff", "percent_diff", "percentdiff", "index" };
if (unsupported.Contains(showAs.ToLowerInvariant()))
    throw new InvalidOperationException($"showDataAs '{showAs}' has no renderer; precompute the transform instead");

Type guard

static readonly HashSet<string> SupportedShowAs = new(StringComparer.OrdinalIgnoreCase)
{ "normal", "percent_of_total", "percent_of_row", "percent_of_col", "running_total" };
static bool IsSupportedShowAs(string s) => SupportedShowAs.Contains(s);

Try / catch

try { BuildPivot(props); }
catch (ArgumentException ex) when (ex.Message.Contains("not yet supported by the renderer"))
{ /* switch to a supported showAs or precompute upstream */ }

Prevention

When it happens

Trigger: values=Sales:sum:difference; values=Sales:sum:percent_diff; values=Sales:sum:index; copying a showDataAs token from an Excel-generated file that uses one of these unsupported modes.

Common situations: User wants period-over-period or indexed calculations and reaches for the OOXML token without realising the renderer only supports percent/running-total family; replaying a spec exported from native Excel that exercises these modes.

Related errors


AI-assisted analysis of iOfficeAI/OfficeCLI@1ced45e900 (2026-08-13). Data as JSON: /api/errors/55f655c605f9cc01. Report an issue: GitHub.