Forum Discussion

JayWee's avatar
JayWee
Frequent Visitor
1 year ago
Solved

Unable to discretely split up dates

Hi All,   I'm having a tough time splitting up dates when using Deneb as i've just started using Power BI and Deneb not that long ago.    The aim is to create something similar to what could be a...
  • MFelix's avatar
    1 year ago

    Hi JayWee ,

     

     

    Not an expert in Vega but I was able to do this using chat GPT:

     

    Preety similar.

    You need to  concatenate the axis to get this working:

    {
      "data": {
        "name": "dataset"
      },
      "transform": [
        {
          "calculate": "timeFormat(toDate(datum.Date), '%d/%m') + ' - ' + datum.Cat",
          "as": "DateCategory"
        }
      ],
      "mark": {
        "type": "line",
        "point": true,
        "tooltip": true
      },
      "encoding": {
        "x": {
          "field": "DateCategory",
          "type": "ordinal",
          "axis": {
            "title": "Date & Category",
            "labelAngle": -45
          }
        },
        "y": {
          "field": "Sum of Value",
          "type": "quantitative",
          "aggregate": "sum",
          "scale": {
            "zero": false
          }
        }
      }
    }

     

    Check the part of the code wher I do the transform of the axis.