Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jasemilly
Helper I
Helper I

Basic Deneb Table change order of columns

Hi I have been following this tutorial and have it working on my own data, I would like to change the order of the columns but can't seem to figure it out or find any examples.

https://www.youtube.com/watch?v=2wZpdZ8hCik&t=466s 

Say I have

ColA     ColB   ColC

and I would like 

ColB  ColC   ColA

thanks for all ideas.

1 ACCEPTED SOLUTION
giammariam
Super User
Super User

If you don't want to bring in an additional sort order field into deneb, you could implement a transform to do the sorting and then use it in the x encoding: 

giammariam_0-1675954861121.png

If this is enough to get you going, please consider kudoing and choosing this reply as the solution. If you need additional help, let me know.

Full spec: 

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": {
    "step": 30
  },
  "data": {
    "url": "https://raw.githubusercontent.com/vega/vega-datasets/next/data/penguins.json"
  },
  "transform": [
    {"window": [{"op": "row_number", "as": "row_num"}]},
    {"filter": {"field": "row_num", "lte": "count"}},
    {"fold": ["Flipper Length (mm)", "Species", "Island", "Sex"]},
    {
      "calculate": "datum['key'] == 'Species' ? 1 : datum['key'] == 'Sex' ? 2 : datum['key'] == 'Island' ? 3 : datum['key'] == 'Flipper Length (mm)' ? 4 : null", "as": "key_sort"
    }
  ],
  "mark": "text",
  "encoding": {
    "y": {"field": "row_num", "type": "ordinal", "axis": null},
    "text": {"field": "value", "type": "nominal"},
    "x": {"field": "key", "sort": {"field": "key_sort"},"type": "nominal", "axis": {"orient": "top", "labelAngle": 0, "title": null, "domain": false, "ticks": false}, "scale": {"padding": 15}}
  }, "config": {"view": {"stroke": null}}
}

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

View solution in original post

2 REPLIES 2
giammariam
Super User
Super User

If you don't want to bring in an additional sort order field into deneb, you could implement a transform to do the sorting and then use it in the x encoding: 

giammariam_0-1675954861121.png

If this is enough to get you going, please consider kudoing and choosing this reply as the solution. If you need additional help, let me know.

Full spec: 

{
  "$schema": "https://vega.github.io/schema/vega-lite/v5.json",
  "width": {
    "step": 30
  },
  "data": {
    "url": "https://raw.githubusercontent.com/vega/vega-datasets/next/data/penguins.json"
  },
  "transform": [
    {"window": [{"op": "row_number", "as": "row_num"}]},
    {"filter": {"field": "row_num", "lte": "count"}},
    {"fold": ["Flipper Length (mm)", "Species", "Island", "Sex"]},
    {
      "calculate": "datum['key'] == 'Species' ? 1 : datum['key'] == 'Sex' ? 2 : datum['key'] == 'Island' ? 3 : datum['key'] == 'Flipper Length (mm)' ? 4 : null", "as": "key_sort"
    }
  ],
  "mark": "text",
  "encoding": {
    "y": {"field": "row_num", "type": "ordinal", "axis": null},
    "text": {"field": "value", "type": "nominal"},
    "x": {"field": "key", "sort": {"field": "key_sort"},"type": "nominal", "axis": {"orient": "top", "labelAngle": 0, "title": null, "domain": false, "ticks": false}, "scale": {"padding": 15}}
  }, "config": {"view": {"stroke": null}}
}

 



Madison Giammaria
Proud to be a Super User 😄
LinkedIn

Do you frequently use Deneb to provide insights to your stakeholders? Have you considered sponsoring this free and open source custom visual? More info here!

@giammariam thank you again worked!!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.