Skip to content

Pivot table totals broken when grouping by foreign key with display value #46919

Closed

Description

Describe the bug

When a question groups values by a foreign key column and that column has Use foreign key selected in the Display values setting of the field settings in Table metadata, the question will no longer correctly work when visualized as Pivot Table .

The grand totals will be missing from the first column making them wrong on questions with multiple columns or leaving them completely empty if only a single column exists.

To Reproduce

  1. Open the admin
  2. Click on Table Metadata
  3. Select the Sample Database
  4. Select "Orders"
  5. Scroll to "Product ID"
  6. Click on the gear icon to the right
  7. Scroll to "Display values"
  8. Select "Use foreign key" > "Title"
  9. Create a new question
  10. Use "Sample Database" -> "Orders"
  11. Under "Summarize" select "Sum of", then "total"
  12. Under "pick column to group by" select "Product ID" below the "Order" heading. Take care not to use Product directly, this will not trigger the bug
  13. Click "row limit", Enter "3". This isn't required, but otherwise you'll have to scroll a lot to see the bug.
  14. Click "Visualize"
  15. Click "Visualization"
  16. Select "Pivot table"
  17. Observe the Grand totals row being completely empty.

Expected behavior

The total should be visible

Logs

No response

Information about your Metabase installation

{
  "browser-info": {
    "language": "en-US",
    "platform": "Linux x86_64",
    "userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/127.0.0.0 Safari/537.36",
    "vendor": "Google Inc."
  },
  "system-info": {
    "file.encoding": "UTF-8",
    "java.runtime.name": "OpenJDK Runtime Environment",
    "java.runtime.version": "11.0.24+8-post-Debian-2deb11u1",
    "java.vendor": "Debian",
    "java.vendor.url": "https://tracker.debian.org/openjdk-11",
    "java.version": "11.0.24",
    "java.vm.name": "OpenJDK 64-Bit Server VM",
    "java.vm.version": "11.0.24+8-post-Debian-2deb11u1",
    "os.name": "Linux",
    "os.version": "5.10.0-31-amd64",
    "user.language": "en",
    "user.timezone": "Etc/UTC"
  },
  "metabase-info": {
    "databases": [
      "h2",
      "postgres"
    ],
    "hosting-env": "unknown",
    "application-database": "postgres",
    "application-database-details": {
      "database": {
        "name": "PostgreSQL",
        "version": "15.8 (Debian 15.8-0+deb12u1)"
      },
      "jdbc-driver": {
        "name": "PostgreSQL JDBC Driver",
        "version": "42.7.3"
      }
    },
    "run-mode": "prod",
    "plan-alias": "",
    "version": {
      "date": "2024-08-13",
      "tag": "v0.50.20",
      "hash": "df82d58"
    },
    "settings": {
      "report-timezone": null
    }
  }
}

Severity

blocking some users, a lot of existing pivot tables are now broken

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

.Frontend.RegressionBugs that were previously fixed and/or bugs unintentionally shipped with new features..Team/QueryingPriority:P1Security holes w/o exploit, crashing, setup/upgrade, login, broken common features, correctnessType:BugProduct defectsVisualization/Tablesraw, summarized and tabular visualizations

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions