Die vollständige Liste der Funktionen, die in Formeln unterstützt werden, finden Sie unter
Funktionsliste. Außerdem finden Sie hier weitere Informationen zu folgenden Themen:
Wenn in einer Formel auf das ID eines anderen Felds verwiesen wird, müssen Sie ihm $ voranstellen. Für
Wenn das Feld ID beispielsweise t_celsius ist, sollte es so bezeichnet werden:
$t_celsius in die Formel ein.
Type für berechnete Felder
Type wird für berechnete Felder unterstützt, die Ausgabe der Formel muss jedoch aktiviert sein.
müssen mit dem erwarteten Format für Type übereinstimmen.
Zum Beispiel für die Formel:
"HYPERLINK($url, $description)"
Der Type sollte HYPERLINK lauten.
aggregation für berechnete Felder
Wenn Ihre Formel eine Aggregation enthält, sollte aggregation auf
AUTO. Sehen Sie in der Funktionsliste in der Spalte type nach, ob eine Funktion
gibt eine Aggregation zurück. Wenn Ihre Formel keine Aggregation enthält, legen Sie diese fest.
an NONE.
Formel
aggregation
"SUM($cost) / SUM($units)"
AUTO
"$cost + $units"
NONE
Beispiele für berechnete Felder in Schemas
functiongetSchema(request){varcc=DataStudioApp.createCommunityConnector();varfields=cc.getFields();vartypes=cc.FieldType;varaggregations=cc.AggregationType;fields.newDimension().setId('date').setName('Date').setDescription('Date of measurement').setType(types.YEAR_MONTH_DAY);fields.newMetric().setId('t_celsius').setName('Temperature (Celsius)').setDescription('Temperature in Celsius').setType(types.NUMBER).setAggregation(aggregations.NONE);fields.newMetric().setId('t_fahrenheit').setName('Temperature (Fahrenheit)').setDescription('Temperature in Fahrenheit').setFormula('$t_celsius / 5 * 9 + 32').setType(types.NUMBER).setAggregation(aggregations.NONE);fields.newMetric().setId('average_temperature (Celsius)').setName('Average Temperature (Celsius)').setDescription('Temperature in Fahrenheit').setFormula('AVG($t_celsius)').setType(types.NUMBER).setAggregation(aggregations.AUTO);fields.newMetric().setId('average_temperature (Celsius)').setName('Average Temperature (Celsius)').setDescription('Temperature in Fahrenheit').setFormula('AVG($t_celsius / 5 * 9 + 32)').setType(types.NUMBER).setAggregation(aggregations.AUTO);fields.newDimension().setId('feels_like').setName('Feels Like').setDescription('What it feels like outside.').setFormula('CASE WHEN $t_celsius < 0 THEN "Freezing" WHEN $t_celsius > 40 THEN "Too warm" ELSE "Not bad" END').setType(types.TEXT);return{'schema':fields.build()};}
[null,null,["Zuletzt aktualisiert: 2025-07-25 (UTC)."],[[["\u003cp\u003eThe \u003ccode\u003eformula\u003c/code\u003e field property enables the addition of calculated fields to your connector's schema using supported functions.\u003c/p\u003e\n"],["\u003cp\u003eWhen referencing other fields within a formula, prefix their \u003ccode\u003eID\u003c/code\u003e with a \u003ccode\u003e$\u003c/code\u003e symbol (e.g., \u003ccode\u003e$fieldName\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eType\u003c/code\u003e property for calculated fields should align with the formula's output format (e.g., \u003ccode\u003eHYPERLINK\u003c/code\u003e for hyperlink formulas).\u003c/p\u003e\n"],["\u003cp\u003eFormulas using aggregation functions require setting the \u003ccode\u003eaggregation\u003c/code\u003e property to \u003ccode\u003eAUTO\u003c/code\u003e, while those without aggregations should use \u003ccode\u003eNONE\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eA comprehensive function list and documentation for specific functions like \u003ccode\u003eCASE\u003c/code\u003e, \u003ccode\u003eCAST\u003c/code\u003e, \u003ccode\u003eTODATE\u003c/code\u003e, and others are available for reference.\u003c/p\u003e\n"]]],[],null,["# Using calculated fields in schema\n\nThe [`formula`](/looker-studio/connector/reference#field.formula) field property can be used to add [calculated fields](https://support.google.com/looker-studio/answer/6299685) to your\nconnector's schema.\n\nThe full list of functions that are supported in formulas can be found at\n[Function List](https://support.google.com/looker-studio/table/6379764). Additionally, there is further documentation for:\n\n- [CASE](https://support.google.com/looker-studio/answer/7020724)\n- [CAST](https://support.google.com/looker-studio/answer/7280720)\n- [TODATE](https://support.google.com/looker-studio/answer/7037300)\n- [HYPERLINK](https://support.google.com/looker-studio/answer/7431836)\n- [IMAGE](https://support.google.com/looker-studio/answer/7570489)\n- [REGEXP_EXTRACT](https://support.google.com/looker-studio/answer/7050487)\n- [REGEXP_MATCH](https://support.google.com/looker-studio/answer/7064476)\n- [REGEXP_REPLACE](https://support.google.com/looker-studio/answer/7067058)\n\n| **Caution:** These function names cannot be used as the `ID` for a field.\n\nWhen referring to another field's `ID` in a formula, prefix it with a `$`. For\nexample, if your field `ID` is `t_celsius`, it should be referred to as\n`$t_celsius` in the formula.\n\n`Type` for calculated fields\n----------------------------\n\n`Type` is supported for calculated fields, but the output of the formula must\nmatch the expected format for that `Type`.\n\nFor example, for the formula: \n\n \"HYPERLINK($url, $description)\"\n\nThe `Type` should be `HYPERLINK`.\n\n`aggregation` for calculated fields\n-----------------------------------\n\nIf your formula involves an aggregation, the `aggregation` should be set to\n`AUTO`. Check the `type` column in the [Function List](https://support.google.com/looker-studio/table/6379764) to see if a function\nreturns an aggregation. If your formula does not involve an aggregation, set it\nto `NONE`.\n\n| Formula | `aggregation` |\n|------------------------------|---------------|\n| `\"SUM($cost) / SUM($units)\"` | `AUTO` |\n| `\"$cost + $units\"` | `NONE` |\n\nExamples of calculated fields in schema\n---------------------------------------\n\n function getSchema(request) {\n var cc = DataStudioApp.createCommunityConnector();\n var fields = cc.getFields();\n var types = cc.FieldType;\n var aggregations = cc.AggregationType;\n\n fields.newDimension()\n .setId('date')\n .setName('Date')\n .setDescription('Date of measurement')\n .setType(types.YEAR_MONTH_DAY);\n\n fields.newMetric()\n .setId('t_celsius')\n .setName('Temperature (Celsius)')\n .setDescription('Temperature in Celsius')\n .setType(types.NUMBER)\n .setAggregation(aggregations.NONE);\n\n fields.newMetric()\n .setId('t_fahrenheit')\n .setName('Temperature (Fahrenheit)')\n .setDescription('Temperature in Fahrenheit')\n .setFormula('$t_celsius / 5 * 9 + 32')\n .setType(types.NUMBER)\n .setAggregation(aggregations.NONE);\n\n fields.newMetric()\n .setId('average_temperature (Celsius)')\n .setName('Average Temperature (Celsius)')\n .setDescription('Temperature in Fahrenheit')\n .setFormula('AVG($t_celsius)')\n .setType(types.NUMBER)\n .setAggregation(aggregations.AUTO);\n\n fields.newMetric()\n .setId('average_temperature (Celsius)')\n .setName('Average Temperature (Celsius)')\n .setDescription('Temperature in Fahrenheit')\n .setFormula('AVG($t_celsius / 5 * 9 + 32)')\n .setType(types.NUMBER)\n .setAggregation(aggregations.AUTO);\n\n fields.newDimension()\n .setId('feels_like')\n .setName('Feels Like')\n .setDescription('What it feels like outside.')\n .setFormula('CASE WHEN $t_celsius \u003c 0 THEN \"Freezing\" WHEN $t_celsius \u003e 40 THEN \"Too warm\" ELSE \"Not bad\" END')\n .setType(types.TEXT);\n\n return { 'schema': fields.build() };\n }\n\n| **Key Point:** `aggregation` is set to `AUTO` for formulas involving aggregations, and `NONE` otherwise."]]