# Substitute() function in Power Query



## Juan Sombrero (Oct 19, 2015)

Hi all,

is anybody aware of an equivalent of the substitue function in M language, comparable to the same function in Excel?

thx,
Juan


----------



## Useful (Oct 19, 2015)

Hello,

use

Text.Replace()

also for more functions follow


----------



## Juan Sombrero (Oct 19, 2015)

Does this allow you to give multiple options (eg 1, january, 2 , februrary, 3, march,....)?


----------



## Useful (Oct 19, 2015)

Juan Sombrero said:


> Does this allow you to give multiple options (eg 1, january, 2 , februrary, 3, march,....)?



it seems you have a date column and you want get month names not?

first change your column type to date and add custom column and use below formula
=Date.ToText([Your_column_name],"MMMM")


----------



## Juan Sombrero (Oct 21, 2015)

Hi,

actually it's the opposite...I have jan, feb, ... and want to convert them to numbers

thx,
Juan


----------



## billszysz (Oct 21, 2015)

Try this code below.

```
let
    MonthList = {"jan","feb","mar","apr","may","jun","jul","aug","sep","oct","nov","dec"},
    Source = Table.FromRows({{"oct",125},{"jul",311}},{"Month","Other"}),
    Result = Table.AddColumn(Source, "MonthNumber", each List.PositionOf(MonthList,[Month])+1)
in
    Result
```

If You don't want an extra column change the Result step to

```
Result = Table.TransformColumns(Source, {{"Month", each List.PositionOf(MonthList,_)+1}})
```

Regards


----------



## Useful (Oct 29, 2015)

Juan Sombrero said:


> Hi,
> 
> actually it's the opposite...I have jan, feb, ... and want to convert them to numbers
> 
> ...



then you may use billszysz's suggestion or create a reference table - month list in excel sheet (desired with month numbers) and use "Merge Queries" method


----------

