Forum Discussion

Marija_JC's avatar
Marija_JC
New Member
1 year ago
Solved

Help with M code conditional column

Hello,  I woluld like to create an coditional column based on the text values from another column. So, it should be like: if column B has value " x", then text in column A sholud start from 4th cha...
  • Omid_Motamedise's avatar
    1 year ago

    use the following formula

    = 
    if [ColumnB] = "x" then
        Text.Middle([ColumnA], 3) 
    else if [ColumnB] = "y" then
        Text.BeforeDelimiter([ColumnA], "-") 
    else if [ColumnB] = "z" then
        Text.BetweenDelimiters([ColumnA], "(", ")") 
    else
        null