Jul 23 2024 06:13 PM
Hi
I imported a table of students marks, and the columns have either marks written or 'Absent'.
Now I want to create another custom function column with 50% of the marks. But if I input the formula such as: 0.5 * [column], it gives error because there's text also.
How can I go around this?
Thanks.
Jul 23 2024 06:23 PM
Jul 24 2024 01:44 AM
If the column with marks is of any data type, that could be
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
GetHalf = Table.AddColumn(
Source,
"50%",
each try [Mark]/2 otherwise [Mark],
type any )
in
GetHalf
if of text type
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
DeclareType = Table.TransformColumnTypes(Source,{{"Mark", type text}}),
GetHalf = Table.AddColumn(
DeclareType,
"50%",
each try Number.FromText([Mark])/2 otherwise [Mark],
type any )
in
GetHalf
Result is like