Skip to content

Commit 279da10

Browse files
committed
Merge branch 'main' into live
2 parents f74e1e6 + 9649130 commit 279da10

1 file changed

Lines changed: 97 additions & 12 deletions

File tree

query-languages/m/table-transformcolumntypes.md

Lines changed: 97 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,120 @@ Table.TransformColumnTypes(<b>table</b> as table, <b>typeTransformations</b> as
1313

1414
## About
1515

16-
Returns a table from the input `table` by applying the transform operation to the columns specified in the parameter `typeTransformations` (where format is { column name, type name}), using the specified culture in the optional parameter `culture` (for example, "en-US"). If the column doesn't exist, an exception is thrown.
16+
Returns a table by applying the transform operations to the specified columns using an optional culture.
17+
18+
* `table`: The input table to transform.
19+
* `typeTransformations`: The type transformations to apply. The format for a single transformation is { column name, type value }. A list of transformations can be used to change the types of more than one column at a time. If a column doesn't exist, an error is raised.
20+
* `culture`: (Optional) The culture to use when transforming the column types (for example, "en-US").
21+
22+
The type value in the `typeTransformations` parameter can be `any`, all of the `number` types, `text`, all of the `date`, `time`, `datetime`, `datetimezone`, and `duration` types, `logical`, or `binary`. The `list`, `record`, `table`, or `function` types aren't valid for this parameter.
1723

1824
## Example 1
1925

20-
Transform the number values in column [a] to text values from the table `({[a = 1, b = 2], [a = 3, b = 4]})`.
26+
Transform the number values in the first column to text values.
2127

2228
**Usage**
2329

2430
```powerquery-m
25-
Table.TransformColumnTypes(
26-
Table.FromRecords({
27-
[a = 1, b = 2],
28-
[a = 3, b = 4]
31+
let
32+
Source = #table(type table [a = number, b = number],
33+
{
34+
{1, 2},
35+
{3, 4}
2936
}),
30-
{"a", type text},
31-
"en-US"
32-
)
37+
#"Transform Column" = Table.TransformColumnTypes(
38+
Source,
39+
{"a", type text}
40+
)
41+
in
42+
#"Transform Column"
3343
```
3444

3545
**Output**
3646

3747
```powerquery-m
38-
Table.FromRecords({
39-
[a = "1", b = 2],
40-
[a = "3", b = 4]
48+
#table(type table [a = text, b = number],
49+
{
50+
{"1", 2},
51+
{"3", 4}
4152
})
4253
```
4354

55+
## Example 2
56+
57+
Transform the dates in the table to their French text equivalents.
58+
59+
**Usage**
60+
61+
```powerquery-m
62+
let
63+
Source = #table(type table [Company ID = text, Country = text, Date = date],
64+
{
65+
{"JS-464", "USA", #date(2024, 3, 24)},
66+
{"LT-331", "France", #date(2024, 10, 5)},
67+
{"XE-100", "USA", #date(2024, 5, 21)},
68+
{"RT-430", "Germany", #date(2024, 1,18)},
69+
{"LS-005", "France", #date(2023, 12, 31)},
70+
{"UW-220", "Germany", #date(2024, 2, 25)}
71+
}),
72+
#"Transform Column" = Table.TransformColumnTypes(
73+
Source,
74+
{"Date", type text},
75+
"fr-FR"
76+
)
77+
in
78+
#"Transform Column"
79+
```
80+
81+
**Output**
82+
83+
```powerquery-m
84+
#table(type table [Company ID = text, Country = text, Date = text],
85+
{
86+
{"JS-464", "USA", "24/03/2024"},
87+
{"LT-331", "France", "05/10/2024"},
88+
{"XE-100", "USA", "21/05/2024"},
89+
{"RT-430", "Germany", "18/01/2024"},
90+
{"LS-005", "France", "31/12/2023"},
91+
{"UW-220", "Germany", "25/02/2024"}
92+
})
93+
```
94+
95+
## Example 3
96+
97+
Transform the dates in the table to their German text equivalents, and the values in the table to percentages.
98+
99+
**Usage**
100+
101+
```powerquery-m
102+
let
103+
Source = #table(type table [Date = date, Customer ID = text, Value = number],
104+
{
105+
{#date(2024, 3, 12), "134282", .24368},
106+
{#date(2024, 5, 30), "44343", .03556},
107+
{#date(2023, 12, 14), "22", .3834}
108+
}),
109+
#"Transform Columns" = Table.TransformColumnTypes(
110+
Source,
111+
{{"Date", type text}, {"Value", Percentage.Type}},
112+
"de-DE")
113+
in
114+
#"Transform Columns"
115+
```
116+
117+
**Output**
118+
119+
```powerquery-m
120+
#table(type table [Date = text, Customer ID = text, Value = Percentage.Type],
121+
{
122+
{"12.03.2024", "134282", .24368},
123+
{"30.05.2024", "44343", .03556},
124+
{"14.12.2023", "22", .3834}
125+
})
126+
```
127+
44128
## Related content
45129

130+
* [Types and type conversion](type-conversion.md)
46131
* [How culture affects text formatting](how-culture-affects-text-formatting.md)
47132
* [Types and type conversion](type-conversion.md)

0 commit comments

Comments
 (0)