Skip to content

Conversation

nickofthyme
Copy link
Contributor

@nickofthyme nickofthyme commented Sep 27, 2025

Summary

When a table from a dashboard using the Download CSV action, the column sort order visible in the table on the dashboard are preserved in the csv output.

Zight.Recording.2025-09-27.at.10.34.45.AM.mp4

Fixes #236550

Details

The datatable_fn is used to set the table of data to the adapters, which is the data used in the csv export action. This data comes in out of order with additional Part of X columns for formula columns. However, we do not sort these in before passing to the adapters. Normally, with formulas, this is not a problem as the columns are in the correct order but the tabify logic mixes up the column order for formulas.

The fix is to simply sort the columns in the table before passing it to the adapters.

Checklist

  • Unit or functional tests were updated or added to match the most common scenarios
  • The PR description includes the appropriate Release Notes section, and the correct release_note:* label is applied per the guidelines
  • Review the backport guidelines and apply applicable backport:* labels.

Release Note

Fixes a bug in the Lens table in which exporting the table from a dashboard, which contains formula columns, can result in a different column order than shown on the dashboard.

@dej611 dej611 added Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// Feature:Lens labels Sep 30, 2025
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-visualizations (Team:Visualizations)

@elasticmachine
Copy link
Contributor

elasticmachine commented Sep 30, 2025

💛 Build succeeded, but was flaky

Failed CI Steps

Metrics [docs]

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
lens 1.5MB 1.5MB +188.0B

History

@nickofthyme nickofthyme merged commit ef105c5 into elastic:main Sep 30, 2025
16 checks passed
@nickofthyme nickofthyme deleted the fix-table-csv-col-order branch September 30, 2025 16:45
@kibanamachine
Copy link
Contributor

Starting backport for target branches: 8.18, 8.19, 9.0, 9.1

https://github.com/elastic/kibana/actions/runs/18137204038

kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 30, 2025
## Summary

When a table from a dashboard using the **Download CSV** action, the
column sort order visible in the table on the dashboard are preserved in
the csv output.

https://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a

Fixes elastic#236550

## Details

The `datatable_fn` is used to set the table of data to the `adapters`,
which is the data used in the csv export action. This data comes in out
of order with additional `Part of X` columns for formula columns.
However, we do not sort these in before passing to the adapters.
Normally, with formulas, this is not a problem as the columns are in the
correct order but the
[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)
logic mixes up the column order for formulas.

The fix is to simply sort the columns in the table before passing it to
the `adapters.`

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Note

Fixes a bug in the Lens table in which exporting the table from a
dashboard, which containg formula columns, can result in a different
column order than shown on the dashboard.

Co-authored-by: Marco Liberati <[email protected]>
(cherry picked from commit ef105c5)
@kibanamachine

This comment was marked as outdated.

nickofthyme added a commit to nickofthyme/kibana that referenced this pull request Sep 30, 2025
## Summary

When a table from a dashboard using the **Download CSV** action, the
column sort order visible in the table on the dashboard are preserved in
the csv output.

https://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a

Fixes elastic#236550

## Details

The `datatable_fn` is used to set the table of data to the `adapters`,
which is the data used in the csv export action. This data comes in out
of order with additional `Part of X` columns for formula columns.
However, we do not sort these in before passing to the adapters.
Normally, with formulas, this is not a problem as the columns are in the
correct order but the
[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)
logic mixes up the column order for formulas.

The fix is to simply sort the columns in the table before passing it to
the `adapters.`

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Note

Fixes a bug in the Lens table in which exporting the table from a
dashboard, which containg formula columns, can result in a different
column order than shown on the dashboard.

Co-authored-by: Marco Liberati <[email protected]>
(cherry picked from commit ef105c5)

# Conflicts:
#	x-pack/platform/plugins/shared/lens/common/expressions/datatable/datatable_fn.test.ts
@nickofthyme
Copy link
Contributor Author

nickofthyme commented Sep 30, 2025

💚 All backports created successfully

Status Branch Result
9.1
9.0
8.19
8.18

Note: Successful backport PRs will be merged automatically after passing CI.

Questions ?

Please refer to the Backport tool documentation

nickofthyme added a commit to nickofthyme/kibana that referenced this pull request Sep 30, 2025
## Summary

When a table from a dashboard using the **Download CSV** action, the
column sort order visible in the table on the dashboard are preserved in
the csv output.

https://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a

Fixes elastic#236550

## Details

The `datatable_fn` is used to set the table of data to the `adapters`,
which is the data used in the csv export action. This data comes in out
of order with additional `Part of X` columns for formula columns.
However, we do not sort these in before passing to the adapters.
Normally, with formulas, this is not a problem as the columns are in the
correct order but the
[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)
logic mixes up the column order for formulas.

The fix is to simply sort the columns in the table before passing it to
the `adapters.`

### Checklist

- [x] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
- [x] The PR description includes the appropriate Release Notes section,
and the correct `release_note:*` label is applied per the
[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)
- [x] Review the [backport
guidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)
and apply applicable `backport:*` labels.

## Release Note

Fixes a bug in the Lens table in which exporting the table from a
dashboard, which containg formula columns, can result in a different
column order than shown on the dashboard.

Co-authored-by: Marco Liberati <[email protected]>
(cherry picked from commit ef105c5)

# Conflicts:
#	x-pack/platform/plugins/shared/lens/common/expressions/datatable/datatable_fn.test.ts
kibanamachine added a commit that referenced this pull request Sep 30, 2025
# Backport

This will backport the following commits from `main` to `9.1`:
- [[Lens][Table] Fix csv export column sort order
(#236673)](#236673)

<!--- Backport version: 9.6.6 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-30T16:45:47Z","message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:all-open","v9.2.0"],"title":"[Lens][Table]
Fix csv export column sort
order","number":236673,"url":"https://github.com/elastic/kibana/pull/236673","mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/236673","number":236673,"mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}}]}]
BACKPORT-->

Co-authored-by: Nick Partridge <[email protected]>
Co-authored-by: Marco Liberati <[email protected]>
nickofthyme added a commit that referenced this pull request Oct 1, 2025
)

# Backport

This will backport the following commits from `main` to `8.18`:
- [[Lens][Table] Fix csv export column sort order
(#236673)](#236673)

<!--- Backport version: 10.0.2 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-30T16:45:47Z","message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:all-open","v9.2.0"],"title":"[Lens][Table]
Fix csv export column sort
order","number":236673,"url":"https://github.com/elastic/kibana/pull/236673","mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/236673","number":236673,"mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}},{"url":"https://github.com/elastic/kibana/pull/237010","number":237010,"branch":"9.1","state":"OPEN"}]}]
BACKPORT-->
nickofthyme added a commit that referenced this pull request Oct 1, 2025
# Backport

This will backport the following commits from `main` to `9.0`:
- [[Lens][Table] Fix csv export column sort order
(#236673)](#236673)

<!--- Backport version: 10.0.2 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-30T16:45:47Z","message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:all-open","v9.2.0"],"title":"[Lens][Table]
Fix csv export column sort
order","number":236673,"url":"https://github.com/elastic/kibana/pull/236673","mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/236673","number":236673,"mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}},{"url":"https://github.com/elastic/kibana/pull/237010","number":237010,"branch":"9.1","state":"OPEN"}]}]
BACKPORT-->
nickofthyme added a commit that referenced this pull request Oct 1, 2025
)

# Backport

This will backport the following commits from `main` to `8.19`:
- [[Lens][Table] Fix csv export column sort order
(#236673)](#236673)

<!--- Backport version: 10.0.2 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sorenlouv/backport)

<!--BACKPORT [{"author":{"name":"Nick
Partridge","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-09-30T16:45:47Z","message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2","branchLabelMapping":{"^v9.2.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:fix","Team:Visualizations","Feature:Lens","backport:all-open","v9.2.0"],"title":"[Lens][Table]
Fix csv export column sort
order","number":236673,"url":"https://github.com/elastic/kibana/pull/236673","mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.2.0","branchLabelMappingKey":"^v9.2.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/236673","number":236673,"mergeCommit":{"message":"[Lens][Table]
Fix csv export column sort order (#236673)\n\n## Summary\n\nWhen a table
from a dashboard using the **Download CSV** action, the\ncolumn sort
order visible in the table on the dashboard are preserved in\nthe csv
output.\n\n\nhttps://github.com/user-attachments/assets/7454a511-150b-45a2-86c5-1cd61bc0191a\n\nFixes
#236550\n\n## Details\n\nThe `datatable_fn` is used to set the table of
data to the `adapters`,\nwhich is the data used in the csv export
action. This data comes in out\nof order with additional `Part of X`
columns for formula columns.\nHowever, we do not sort these in before
passing to the adapters.\nNormally, with formulas, this is not a problem
as the columns are in the\ncorrect order but
the\n[`tabify`](https://github.com/elastic/kibana/blob/8d4b0956586284c35db97de2baea49b58476ee2a/src/platform/plugins/shared/data/common/search/tabify/tabify.ts#L24)\nlogic
mixes up the column order for formulas.\n\nThe fix is to simply sort the
columns in the table before passing it to\nthe `adapters.`\n\n###
Checklist\n\n- [x] [Unit or
functional\ntests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)\nwere
updated or added to match the most common scenarios\n- [x] The PR
description includes the appropriate Release Notes section,\nand the
correct `release_note:*` label is applied per
the\n[guidelines](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process)\n-
[x] Review the
[backport\nguidelines](https://docs.google.com/document/d/1VyN5k91e5OVumlc0Gb9RPa3h1ewuPE705nRtioPiTvY/edit?usp=sharing)\nand
apply applicable `backport:*` labels.\n\n## Release Note\n\nFixes a bug
in the Lens table in which exporting the table from a\ndashboard, which
containg formula columns, can result in a different\ncolumn order than
shown on the dashboard.\n\nCo-authored-by: Marco Liberati
<[email protected]>","sha":"ef105c5c34b15a30ab5a90c2e1573af62cb692d2"}},{"url":"https://github.com/elastic/kibana/pull/237010","number":237010,"branch":"9.1","state":"OPEN"}]}]
BACKPORT-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:all-open Backport to all branches that could still receive a release Feature:Lens release_note:fix Team:Visualizations Team label for Lens, elastic-charts, Graph, legacy editors (TSVB, Visualize, Timelion) t// v8.18.8 v8.19.5 v9.0.8 v9.1.5 v9.2.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Lens] CSV columns order is different from the one shown on the Datatable
4 participants