{
  "$schema": "https://vega.github.io/schema/vega-lite/v6.json",
  "description": "Plantilla gratis para Deneb, con el spec y el proyecto PBIP. Ventas por año bajo los cuatro elementos de un grupo de comparación con el año anterior. Por CSalcedoDataBI · https://csalcedodatabi.com/deneb/comparativa-interanual-grupo-calculo",
  "usermeta": {
    "information": {
      "uuid": "7e4e0899-cf45-43c6-9f86-2da763c39c53",
      "generated": "2026-11-05T00:00:00Z",
      "previewImageBase64PNG": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII=",
      "name": "Interanual, celda a celda",
      "description": "Comparación con el año anterior. Cuatro elementos de inteligencia de tiempo sobre la misma medida, donde SOLO Diferencia % sobrescribe el formato; los otros tres conservan el de la medida. Técnica: grupo de cálculo de time intelligence leído en Deneb por __formatted. Autor: Cristobal Salcedo Beltrán.",
      "author": "Cristobal Salcedo Beltrán"
    },
    "deneb": {
      "build": "1.9.0",
      "metaVersion": 1,
      "provider": "vegaLite",
      "providerVersion": "6.4.1"
    },
    "interactivity": {
      "tooltip": false,
      "contextMenu": true,
      "selection": false,
      "selectionMode": "simple",
      "highlight": false,
      "dataPointLimit": 50
    },
    "config": "{\n  \"view\": {\n    \"stroke\": null\n  }\n}",
    "dataset": [
      {
        "key": "__0__",
        "name": "TimeIntel",
        "description": "Columna del grupo de cálculo de comparación con el año anterior",
        "kind": "column",
        "type": "text"
      },
      {
        "key": "__1__",
        "name": "Year",
        "description": "Año de DimDate: una fila por año",
        "kind": "column",
        "type": "numeric"
      },
      {
        "key": "__2__",
        "name": "Total Sales",
        "description": "Medida explícita; activa Formatted value en Supporting fields",
        "kind": "measure",
        "type": "numeric"
      }
    ]
  },
  "background": "#FFFFFF",
  "title": {
    "text": "Solo «Diferencia %» cambia el formato",
    "subtitle": "Ventas por año con cuatro elementos de comparación con el año anterior",
    "anchor": "start",
    "offset": 18,
    "font": "Segoe UI",
    "fontSize": 20,
    "fontWeight": 600,
    "color": "#1B1A19",
    "subtitleFont": "Segoe UI",
    "subtitleFontSize": 13,
    "subtitleColor": "#605E5C",
    "subtitlePadding": 8
  },
  "padding": {
    "top": 14,
    "left": 14,
    "right": 26,
    "bottom": 16
  },
  "spacing": 26,
  "vconcat": [
    {
      "data": {
        "name": "dataset"
      },
      "transform": [
        {
          "calculate": "isValid(datum['__0__']) ? datum['__0__'] : 'AUSENTE'",
          "as": "columna"
        },
        {
          "calculate": "'' + datum['__1__']",
          "as": "fila"
        },
        {
          "calculate": "isValid(datum['__2____formatted']) ? datum['__2____formatted'] : 'sin dato'",
          "as": "valor"
        },
        {
          "calculate": "datum['__1__'] % 2",
          "as": "par"
        }
      ],
      "encoding": {
        "x": {
          "field": "columna",
          "type": "nominal",
          "sort": [
            "Medida seleccionada",
            "Año anterior",
            "Diferencia",
            "Diferencia %"
          ],
          "axis": {
            "orient": "top",
            "title": null,
            "labelAngle": 0,
            "labelFont": "Segoe UI",
            "labelFontSize": 12,
            "labelFontWeight": 600,
            "labelColor": "#605E5C",
            "labelPadding": 14,
            "domain": false,
            "ticks": false,
            "labelLimit": 185
          }
        },
        "y": {
          "field": "fila",
          "type": "nominal",
          "axis": {
            "title": null,
            "labelFont": "Segoe UI",
            "labelFontSize": 14,
            "labelFontWeight": 600,
            "labelColor": "#1B1A19",
            "labelPadding": 16,
            "domain": false,
            "ticks": false
          }
        }
      },
      "layer": [
        {
          "mark": {
            "type": "rect",
            "fill": "#F3F7F6"
          },
          "encoding": {
            "opacity": {
              "condition": {
                "test": "datum.par === 1",
                "value": 1
              },
              "value": 0
            },
            "x": null
          }
        },
        {
          "mark": {
            "type": "text",
            "fontSize": 16,
            "font": "Consolas",
            "fontWeight": 600
          },
          "encoding": {
            "text": {
              "field": "valor",
              "type": "nominal"
            },
            "color": {
              "condition": [
                {
                  "test": "datum.valor === 'sin dato'",
                  "value": "#A19F9D"
                },
                {
                  "test": "datum.columna === 'Diferencia %'",
                  "value": "#0E7C6B"
                }
              ],
              "value": "#1B1A19"
            }
          }
        }
      ],
      "width": {
        "step": 195
      },
      "height": {
        "step": 58
      }
    },
    {
      "data": {
        "values": [
          {
            "x": 0
          }
        ]
      },
      "width": 780,
      "height": 136,
      "layer": [
        {
          "mark": {
            "type": "rect",
            "x": -52,
            "x2": 780,
            "y": 0,
            "y2": 136,
            "fill": "#F0F7F5",
            "cornerRadius": 8
          }
        },
        {
          "mark": {
            "type": "rect",
            "x": -52,
            "x2": -47,
            "y": 0,
            "y2": 136,
            "fill": "#0E7C6B",
            "cornerRadiusTopLeft": 8,
            "cornerRadiusBottomLeft": 8
          }
        },
        {
          "mark": {
            "type": "text",
            "x": -28,
            "y": 22,
            "align": "left",
            "baseline": "middle",
            "text": "QUÉ MIRAR",
            "font": "Segoe UI",
            "fontSize": 11,
            "fontWeight": 700,
            "color": "#0E7C6B"
          }
        },
        {
          "mark": {
            "type": "text",
            "x": -28,
            "y": 46,
            "align": "left",
            "baseline": "top",
            "text": [
              "Cuatro elementos sobre la misma medida y solo «Diferencia %» cambia",
              "el formato; los otros tres conservan la moneda. 2023 aparece",
              "incompleto a propósito: no tiene año anterior con el que comparar,",
              "así que la diferencia iguala a las ventas."
            ],
            "font": "Segoe UI",
            "fontSize": 13,
            "lineHeight": 19,
            "color": "#1B1A19"
          }
        }
      ],
      "view": {
        "stroke": null
      }
    }
  ],
  "config": {
    "view": {
      "stroke": null
    },
    "axis": {
      "grid": false
    },
    "concat": {
      "spacing": 26
    }
  }
}