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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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