Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
1 year ago
Solved

if condition for M code

Hi,   I'm using this dax but how can I write M code in query when create new custom column? Also is there any way change the values directly without adding new column?      IF([MRBTS ID] < 1130...
  • hnam_2006's avatar
    1 year ago

    Hi

     

    You can use the "conditional column" option in add column ribbon option. Make sure you define each condition in seperate line

     

     

    Or if you want to write the code, you can use below code option

     

    = Table.AddColumn(YourPreviousStepName, "New Column", each 
        if [MRBTS ID] < 113000 then "A" 
        else if [MRBTS ID] >= 113000 and [MRBTS ID] < 125401 then "B" 
        else if [MRBTS ID] >= 125401 and [MRBTS ID] < 130000 then "C" 
        else if [MRBTS ID] >= 130000 and [MRBTS ID] < 160000 then "D" 
        else null)

     

    Best Regards,
    hnam_2006
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.