|
| 1 | +--- |
| 2 | +title: Work with Dataverse formula columns |
| 3 | +description: Learn how to create and use formula columns in Microsoft Dataverse. |
| 4 | +author: matp |
| 5 | +reviewer: mattp123 |
| 6 | +ms.topic: how-to |
| 7 | +ms.custom: |
| 8 | +ms.date: 07/13/2022 |
| 9 | +ms.subservice: teams |
| 10 | +ms.author: dikamath |
| 11 | +ms.reviewer: matp |
| 12 | +contributors: |
| 13 | + - mattp123 |
| 14 | +--- |
| 15 | + |
| 16 | +# Work with formula columns (preview) |
| 17 | + |
| 18 | +[!INCLUDE [cc-beta-prerelease-disclaimer](../../includes/cc-beta-prerelease-disclaimer.md)] |
| 19 | + |
| 20 | +Formula columns are columns that display a calculated value in a Microsoft Dataverse table. Formulas use [Power Fx](/power-platform/power-fx/overview), a powerful but human-friendly programming language. Build a formula in a Dataverse formula column the same way you would build a formula in Microsoft Excel. As you type, Intellisense suggests functions and syntax, and even helps you fix errors. |
| 21 | + |
| 22 | +> [!NOTE] |
| 23 | +> Formula columns can be added as a calculated field. Currently, formula columns can't be used in roll-up fields or with plugins. |
| 24 | +
|
| 25 | +## Add a formula column |
| 26 | + |
| 27 | +1. Sign in to Power Apps at [https://make.powerapps.com](https://make.powerapps.com/?utm_source=padocs&utm_medium=linkinadoc&utm_campaign=referralsfromdoc). |
| 28 | +1. Select **Dataverse** > **Tables**, and then select the table where you want to add a formula column. |
| 29 | +1. Select the **Columns** area, and then select **New column**. |
| 30 | +1. Enter a **Display name** for the column. |
| 31 | +1. Optionally, enter a **Description** of the column. |
| 32 | +1. In **Data type**, select ***fx* Formula**. |
| 33 | +1. Enter the formula in the **Formula** box. |
| 34 | +1. Select **Save**. |
| 35 | + |
| 36 | +The following example creates a formula column called *Total price*. The *Number of units* column is a whole number data type. The *Price* column is a decimal data type. |
| 37 | + |
| 38 | +:::image type="content" source="media/create-formula-column-dataverse.png" alt-text="Screenshot of a formula column definition."::: |
| 39 | + |
| 40 | +The formula column displays the result of *Price* multiplied by *Number of units*. |
| 41 | + |
| 42 | +:::image type="content" source="media/record-in-app-formula-column.png" alt-text="Screenshot of a record with a formula column."::: |
| 43 | + |
| 44 | +The formula that you enter determines the column type. You can't change a column type after the column is created. That means you can change the formula after you’ve created the column only if it doesn’t change the column type. |
| 45 | + |
| 46 | +For example, the formula *price * discount* creates a column type of number. You can change *price * discount* to *price * (discount + 10%)* because that doesn’t change the column type. However, you can’t change *price * discount* to *Text(price * discount)* because that would require changing the column type to string. |
| 47 | + |
| 48 | +## Operators |
| 49 | + |
| 50 | +You can use the following operators in a formula column: |
| 51 | ++, -, \*, /, %, ^, in, exactin, & |
| 52 | + |
| 53 | +For more information, go to [Operators in Power Apps](../canvas-apps/functions/operators.md). |
| 54 | + |
| 55 | +## Data types |
| 56 | + |
| 57 | +You can display the following data types in a formula column: |
| 58 | + |
| 59 | +- Text |
| 60 | +- Decimal Number |
| 61 | +- Yes/No (boolean) |
| 62 | +- Date |
| 63 | + |
| 64 | +The Currency data type isn't currently supported. |
| 65 | + |
| 66 | +## Function types |
| 67 | + |
| 68 | +You can use the following function types in a formula column: |
| 69 | + |
| 70 | +- Decimal |
| 71 | +- String |
| 72 | +- Boolean |
| 73 | +- Option Set |
| 74 | +- DateTime (TZI) |
| 75 | +- DateTime (User local) (limited to comparisons with other user local values and the DateAdd function) |
| 76 | +- DateTime (Date only) (limited to comparisons with other date-only values, and the DateAdd function) |
| 77 | +- Currency |
| 78 | +- Whole Number, promoted to Decimal |
| 79 | + |
| 80 | +## Functions |
| 81 | + |
| 82 | +You can use the following scalar functions in a formula column: |
| 83 | + |
| 84 | +:::row::: |
| 85 | + :::column span=""::: |
| 86 | + [Abs](../canvas-apps/functions/function-numericals.md) |
| 87 | + :::column-end::: |
| 88 | + :::column span=""::: |
| 89 | + [And](../canvas-apps/functions/function-logicals.md) |
| 90 | + :::column-end::: |
| 91 | + :::column span=""::: |
| 92 | + [Average](../canvas-apps/functions/function-aggregates.md) |
| 93 | + :::column-end::: |
| 94 | +:::row-end::: |
| 95 | +:::row::: |
| 96 | + :::column span=""::: |
| 97 | + [Blank](../canvas-apps/functions/function-isblank-isempty.md) |
| 98 | + :::column-end::: |
| 99 | + :::column span=""::: |
| 100 | + [Char](../canvas-apps/functions/function-char.md) |
| 101 | + :::column-end::: |
| 102 | + :::column span=""::: |
| 103 | + [Concatenate](../canvas-apps/functions/function-concatenate.md) |
| 104 | + :::column-end::: |
| 105 | +:::row-end::: |
| 106 | +:::row::: |
| 107 | + :::column span=""::: |
| 108 | + [DateAdd](../canvas-apps/functions/function-dateadd-datediff.md) |
| 109 | + :::column-end::: |
| 110 | + :::column span=""::: |
| 111 | + [DateDiff](../canvas-apps/functions/function-dateadd-datediff.md) |
| 112 | + :::column-end::: |
| 113 | + :::column span=""::: |
| 114 | + [Day](../canvas-apps/functions/function-datetime-parts.md) |
| 115 | + :::column-end::: |
| 116 | +:::row-end::: |
| 117 | +:::row::: |
| 118 | + :::column span=""::: |
| 119 | + [EndsWith](../canvas-apps/functions/function-startswith.md) |
| 120 | + :::column-end::: |
| 121 | + :::column span=""::: |
| 122 | + [Exp](../canvas-apps/functions/function-numericals.md) |
| 123 | + :::column-end::: |
| 124 | + :::column span=""::: |
| 125 | + [Hour](../canvas-apps/functions/function-datetime-parts.md) |
| 126 | + :::column-end::: |
| 127 | +:::row-end::: |
| 128 | +:::row::: |
| 129 | + :::column span=""::: |
| 130 | + [If](../canvas-apps/functions/function-if.md) |
| 131 | + :::column-end::: |
| 132 | + :::column span=""::: |
| 133 | + [IfError](../canvas-apps/functions/function-iferror.md) |
| 134 | + :::column-end::: |
| 135 | + :::column span=""::: |
| 136 | + [Int](../canvas-apps/functions/function-round.md) |
| 137 | + :::column-end::: |
| 138 | +:::row-end::: |
| 139 | +:::row::: |
| 140 | + :::column span=""::: |
| 141 | + [IsBlank](../canvas-apps/functions/function-isblank-isempty.md) |
| 142 | + :::column-end::: |
| 143 | + :::column span=""::: |
| 144 | + [IsError](../canvas-apps/functions/function-iferror.md) |
| 145 | + :::column-end::: |
| 146 | + :::column span=""::: |
| 147 | + [ISOWeekNum](../canvas-apps/functions/function-weeknum.md) |
| 148 | + :::column-end::: |
| 149 | +:::row-end::: |
| 150 | +:::row::: |
| 151 | + :::column span=""::: |
| 152 | + [IsUTCToday](../canvas-apps/functions/function-now-today-istoday.md) |
| 153 | + :::column-end::: |
| 154 | + :::column span=""::: |
| 155 | + [Left](../canvas-apps/functions/function-left-mid-right.md) |
| 156 | + :::column-end::: |
| 157 | + :::column span=""::: |
| 158 | + [Len](../canvas-apps/functions/function-len.md) |
| 159 | + :::column-end::: |
| 160 | +:::row-end::: |
| 161 | +:::row::: |
| 162 | + :::column span=""::: |
| 163 | + [Ln](../canvas-apps/functions/function-numericals.md) |
| 164 | + :::column-end::: |
| 165 | + :::column span=""::: |
| 166 | + [Lower](../canvas-apps/functions/function-lower-upper-proper.md) |
| 167 | + :::column-end::: |
| 168 | + :::column span=""::: |
| 169 | + [Max](../canvas-apps/functions/function-aggregates.md) |
| 170 | + :::column-end::: |
| 171 | +:::row-end::: |
| 172 | +:::row::: |
| 173 | + :::column span=""::: |
| 174 | + [Mid](../canvas-apps/functions/function-left-mid-right.md) |
| 175 | + :::column-end::: |
| 176 | + :::column span=""::: |
| 177 | + [Min](../canvas-apps/functions/function-aggregates.md) |
| 178 | + :::column-end::: |
| 179 | + :::column span=""::: |
| 180 | + [Minute](../canvas-apps/functions/function-datetime-parts.md) |
| 181 | + :::column-end::: |
| 182 | +:::row-end::: |
| 183 | +:::row::: |
| 184 | + :::column span=""::: |
| 185 | + [Mod](../canvas-apps/functions/function-mod.md) |
| 186 | + :::column-end::: |
| 187 | + :::column span=""::: |
| 188 | + [Month](../canvas-apps/functions/function-datetime-parts.md) |
| 189 | + :::column-end::: |
| 190 | + :::column span=""::: |
| 191 | + [Not](../canvas-apps/functions/function-logicals.md) |
| 192 | + :::column-end::: |
| 193 | +:::row-end::: |
| 194 | +:::row::: |
| 195 | + :::column span=""::: |
| 196 | + [Or](../canvas-apps/functions/function-logicals.md) |
| 197 | + :::column-end::: |
| 198 | + :::column span=""::: |
| 199 | + [Power](../canvas-apps/functions/function-numericals.md) |
| 200 | + :::column-end::: |
| 201 | + :::column span=""::: |
| 202 | + [Replace](../canvas-apps/functions/function-replace-substitute.md) |
| 203 | + :::column-end::: |
| 204 | +:::row-end::: |
| 205 | +:::row::: |
| 206 | + :::column span=""::: |
| 207 | + [Right](../canvas-apps/functions/function-left-mid-right.md) |
| 208 | + :::column-end::: |
| 209 | + :::column span=""::: |
| 210 | + [Round](../canvas-apps/functions/function-round.md) |
| 211 | + :::column-end::: |
| 212 | + :::column span=""::: |
| 213 | + [RoundDown](../canvas-apps/functions/function-round.md) |
| 214 | + :::column-end::: |
| 215 | +:::row-end::: |
| 216 | +:::row::: |
| 217 | + :::column span=""::: |
| 218 | + [RoundUp](../canvas-apps/functions/function-round.md) |
| 219 | + :::column-end::: |
| 220 | + :::column span=""::: |
| 221 | + [Second](../canvas-apps/functions/function-datetime-parts.md) |
| 222 | + :::column-end::: |
| 223 | + :::column span=""::: |
| 224 | + [Sqrt](../canvas-apps/functions/function-numericals.md) |
| 225 | + :::column-end::: |
| 226 | +:::row-end::: |
| 227 | +:::row::: |
| 228 | + :::column span=""::: |
| 229 | + [StartsWith](../canvas-apps/functions/function-startswith.md) |
| 230 | + :::column-end::: |
| 231 | + :::column span=""::: |
| 232 | + [Substitute](../canvas-apps/functions/function-replace-substitute.md) |
| 233 | + :::column-end::: |
| 234 | + :::column span=""::: |
| 235 | + [Sum](../canvas-apps/functions/function-aggregates.md) |
| 236 | + :::column-end::: |
| 237 | +:::row-end::: |
| 238 | +:::row::: |
| 239 | + :::column span=""::: |
| 240 | + [Switch](../canvas-apps/functions/function-if.md) |
| 241 | + :::column-end::: |
| 242 | + :::column span=""::: |
| 243 | + [Text](../canvas-apps/functions/function-text.md) \* |
| 244 | + :::column-end::: |
| 245 | + :::column span=""::: |
| 246 | + [Trim](../canvas-apps/functions/function-trim.md) |
| 247 | + :::column-end::: |
| 248 | +:::row-end::: |
| 249 | +:::row::: |
| 250 | + :::column span=""::: |
| 251 | + [Trunc](../canvas-apps/functions/function-round.md) |
| 252 | + :::column-end::: |
| 253 | + :::column span=""::: |
| 254 | + [TrimEnds](../canvas-apps/functions/function-trim.md) |
| 255 | + :::column-end::: |
| 256 | + :::column span=""::: |
| 257 | + [Upper](../canvas-apps/functions/function-lower-upper-proper.md) |
| 258 | + :::column-end::: |
| 259 | +:::row-end::: |
| 260 | +:::row::: |
| 261 | + :::column span=""::: |
| 262 | + [UTCNow](../canvas-apps/functions/function-now-today-istoday.md) |
| 263 | + :::column-end::: |
| 264 | + :::column span=""::: |
| 265 | + [UTCToday](../canvas-apps/functions/function-now-today-istoday.md) |
| 266 | + :::column-end::: |
| 267 | + :::column span=""::: |
| 268 | + [Value](../canvas-apps/functions/function-value.md) \* |
| 269 | + :::column-end::: |
| 270 | +:::row-end::: |
| 271 | +:::row::: |
| 272 | + :::column span=""::: |
| 273 | + [Weekday](../canvas-apps/functions/function-datetime-parts.md) |
| 274 | + :::column-end::: |
| 275 | + :::column span=""::: |
| 276 | + [WeekNum](../canvas-apps/functions/function-weeknum.md) |
| 277 | + :::column-end::: |
| 278 | + :::column span=""::: |
| 279 | + [Year](../canvas-apps/functions/function-datetime-parts.md) |
| 280 | + :::column-end::: |
| 281 | +:::row-end::: |
| 282 | + |
| 283 | +\* The **Text** and **Value** functions only work with whole numbers, where no decimal separator is involved. The decimal separator varies across locales. Since formula columns are evaluated without locale knowledge, there's no way to properly interpret or generate the decimal separator. |
| 284 | + |
| 285 | +### See also |
| 286 | + |
| 287 | +[Types of columns](types-of-fields.md) |
| 288 | +[Microsoft Power Fx overview](/power-platform/power-fx/overview) |
0 commit comments