{
 "models": [
  {
   "id": "demo"
  }
 ],
 "tables": [
  {
   "modelId": "demo",
   "id": "periods",
   "dims": [
    {
     "id": "Frame",
     "type": "string"
    }
   ]
  },
  {
   "modelId": "demo",
   "id": "lines",
   "dims": [
    {
     "id": "Name",
     "type": "string"
    }
   ]
  },
  {
   "modelId": "demo",
   "id": "drivers",
   "dims": [
    {
     "id": "value",
     "type": "number"
    }
   ]
  },
  {
   "modelId": "demo",
   "id": "is",
   "isPivot": true,
   "dims": [
    {
     "id": "line",
     "refModelId": "demo",
     "refTableId": "lines",
     "refDimId": "id"
    },
    {
     "id": "year",
     "refModelId": "demo",
     "refTableId": "periods",
     "refDimId": "id"
    },
    {
     "id": "value",
     "type": "number"
    },
    {
     "id": "frame",
     "linkedToPdimId": "year",
     "fetchDimId": "Frame"
    }
   ],
   "pivot": {
    "vdimIds": [
     "line"
    ],
    "hdimIds": [
     "year"
    ],
    "cdimIds": [
     "value"
    ],
    "periodsDimId": "year"
   },
   "condObjs": [
    {
     "type": "format",
     "name": "money",
     "dimId": "value",
     "condition": [],
     "data": "{\"comma\":true,\"decimals\":0}"
    },
    {
     "type": "format",
     "name": "percent",
     "dimId": "value",
     "condition": [
      {
       "left": "line",
       "comparison": "=",
       "right": "growth",
       "join": "OR"
      },
      {
       "left": "line",
       "comparison": "=",
       "right": "gm",
       "join": "OR"
      },
      {
       "left": "line",
       "comparison": "=",
       "right": "opm"
      }
     ],
     "data": "{\"postfix\":\"%\",\"pow\":2,\"decimals\":1}"
    }
   ]
  }
 ],
 "methods": [
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "growth_hist",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "growth"
    },
    {
     "left": "frame",
     "comparison": "=",
     "right": "hist"
    }
   ],
   "formula": "IFERROR('revenue' / 'prior revenue' - 1, \"\")"
  },
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "revenue_fcst",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "revenue"
    },
    {
     "left": "frame",
     "comparison": "=",
     "right": "fcst"
    }
   ],
   "formula": "'prior revenue' * (1 + 'growth')"
  },
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "cogs_fcst",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "cogs"
    },
    {
     "left": "frame",
     "comparison": "=",
     "right": "fcst"
    }
   ],
   "formula": "'revenue' * LOOKUP(\"value\",\"drivers\",\"id\",\"cogs_pct\")"
  },
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "opex_fcst",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "opex"
    },
    {
     "left": "frame",
     "comparison": "=",
     "right": "fcst"
    }
   ],
   "formula": "'prior opex' * (1 + LOOKUP(\"value\",\"drivers\",\"id\",\"opex_growth\"))"
  },
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "gross_profit",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "gp"
    }
   ],
   "formula": "'revenue' - 'cogs'"
  },
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "gross_margin",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "gm"
    }
   ],
   "formula": "'gp' / 'revenue'"
  },
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "op_income",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "opinc"
    }
   ],
   "formula": "'gp' - 'opex'"
  },
  {
   "modelId": "demo",
   "tableId": "is",
   "name": "op_margin",
   "dimId": "value",
   "condition": [
    {
     "left": "line",
     "comparison": "=",
     "right": "opm"
    }
   ],
   "formula": "'opinc' / 'revenue'"
  }
 ],
 "data": {
  "demo:periods": {
   "dimIds": [
    "id",
    "Frame"
   ],
   "records": [
    [
     "2024",
     "hist"
    ],
    [
     "2025",
     "hist"
    ],
    [
     "2026",
     "fcst"
    ],
    [
     "2027",
     "fcst"
    ],
    [
     "2028",
     "fcst"
    ]
   ]
  },
  "demo:lines": {
   "dimIds": [
    "id",
    "Name"
   ],
   "records": [
    [
     "revenue",
     "Revenue"
    ],
    [
     "growth",
     "Revenue growth"
    ],
    [
     "cogs",
     "COGS"
    ],
    [
     "gp",
     "Gross profit"
    ],
    [
     "gm",
     "Gross margin"
    ],
    [
     "opex",
     "Opex"
    ],
    [
     "opinc",
     "Operating income"
    ],
    [
     "opm",
     "Operating margin"
    ]
   ]
  },
  "demo:drivers": {
   "dimIds": [
    "id",
    "value"
   ],
   "records": [
    [
     "cogs_pct",
     0.38
    ],
    [
     "opex_growth",
     0.1
    ]
   ]
  },
  "demo:is": {
   "dimIds": [
    "line",
    "year",
    "value"
   ],
   "records": [
    [
     "revenue",
     "2024",
     1000
    ],
    [
     "revenue",
     "2025",
     1200
    ],
    [
     "cogs",
     "2024",
     420
    ],
    [
     "cogs",
     "2025",
     480
    ],
    [
     "opex",
     "2024",
     380
    ],
    [
     "opex",
     "2025",
     430
    ],
    [
     "growth",
     "2026",
     0.18
    ],
    [
     "growth",
     "2027",
     0.15
    ],
    [
     "growth",
     "2028",
     0.12
    ]
   ]
  }
 }
}