1

I am trying to create this custom gantt chart visual with Deneb. I would like to add a parent column and would like it to replicate the tabular format of a matrix. I am able to create the new column using calculate to create parent subgroups but need help to only show the first value in my parent subgroup in Deneb so it looks like the PBI native matrix tabular format. I don't know if this is possible but thank you so much for your help in advance!!

This is what I current have in Deneb: Deneb Table with parent and child columns

This is what I would like to replicate in Deneb:

PBI tabular matrix

upentropy_22_1-1746026918408.png

    {
 "data": {"name": "dataset"},
 "spacing": 12,
 "transform": [
 {
 "calculate": "datum['Sort Order'] === 1 || datum['Sort Order'] === 2 || datum['Sort Order'] === 3 ? 'Fruit' : null",
 "as": "Parent1"
},
{
 "calculate": "datum['Sort Order'] === 4 || datum['Sort Order'] === 5 || datum['Sort Order'] === 6 ? 'Vegetables' : null",
 "as": "Parent2"
},
 {
 "calculate": "datum.Parent1 || datum.Parent2",
 "as": "Parent"
 },
 {
 "window": [
  {"op": "first_value", "field": "Parent", "as": "Parent Test"}
],
 "frame": [null, null],
 "groupby": ["Parent"]
 },
 {
 "filter": "datum['Parent Test'] !== null"
 }
],
 "hconcat": [
 {
"mark": {"type": "text"},
"encoding": {
 "y": {
 "field": "Level 2",
 "type": "ordinal",
"axis": null,
 "sort": {
 "field": "Sort Order",
"order": "ascending"
 }
},
"text": {
   "field": "Parent Test"}
 }
 },
 { "mark": {"type": "text"},
 "encoding": {
 "y": {
 "field": "Level 2",
"type": "ordinal",
"axis": null,
 "sort": {
 "field": "Sort Order",
"order": "ascending" }
 },
 "text": {
 "field": "Level 2",
 "type": "nominal"
 }
 } }
]
}

Data

Level 2Sort OrderLevel 1 Strawberry 1 Fruit Apple 2 Fruit Banana 3 Fruit Cucumber 4 Vegetable Zuchini 5 Vegetable Pepper 6 Vegetable

5
  • Have you seen the Gantt on this page which is ready to use? github.com/PBI-David/Deneb-Showcase Commented Apr 30 at 16:14
  • Thank you yes I have! But to save on vertical space, I have to create a separate column with the parents instead of having them be indented like in your example. Commented Apr 30 at 16:35
  • OK. Add a row number using window transform and blank out the value using calculate unless it is the first in the group. If you supply a .pbix, I can show you. Commented Apr 30 at 16:43
  • I have created a much simpler Gantt chart using Vega-Lite because I just need to see an actual and a baseline duration for all of my cycles. Commented Apr 30 at 16:47
  • Thank you so much but my work account settings are not letting me upload the pbix file. I updated the post with my mock data that corresponds to the code above. Would that work hopefully? Commented Apr 30 at 16:57

1 Answer 1

0

Try this. I don't understand your approach so I have left it exactly the same and added just two transforms.

enter image description here

{
  "data": {
    "name": "dataset"
  },
  "spacing": 12,
  "transform": [
    {
      "calculate": "datum['Sort Order'] === 1 || datum['Sort Order'] === 2 || datum['Sort Order'] === 3 ? 'Fruit' : null",
      "as": "Parent1"
    },
    {
      "calculate": "datum['Sort Order'] === 4 || datum['Sort Order'] === 5 || datum['Sort Order'] === 6 ? 'Vegetables' : null",
      "as": "Parent2"
    },
    {
      "calculate": "datum.Parent1 || datum.Parent2",
      "as": "Parent"
    },
    {
      "window": [
        {
          "op": "first_value",
          "field": "Parent",
          "as": "Parent Test"
        }
      ],
      "frame": [
        null,
        null
      ],
      "groupby": [
        "Parent"
      ]
    },
    {
      "filter": "datum['Parent Test'] !== null"
    },
    {
       "sort": [
      {"field": "Sort Order", "order": "ascending"}
    ],
    "window": [{
      "op": "row_number"
    }],
    "groupby": ["Parent"]
  },
  {
      "calculate": "datum.row_number==1?datum['Parent Test']:'' ",
      "as": "Parent Test"
    }
  ],
  "hconcat": [
    {
      "mark": {
        "type": "text"
      },
      "encoding": {
        "y": {
          "field": "Level 2",
          "type": "ordinal",
          "axis": null,
          "sort": {
            "field": "Sort Order",
            "order": "ascending"
          }
        },
        "text": {
          "field": "Parent Test"
        }
      }
    },
    {
      "mark": {
        "type": "text"
      },
      "encoding": {
        "y": {
          "field": "Level 2",
          "type": "ordinal",
          "axis": null,
          "sort": {
            "field": "Sort Order",
            "order": "ascending"
          }
        },
        "text": {
          "field": "Level 2",
          "type": "nominal"
        }
      }
    }
  ]
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.