cancel
Showing results for
Did you mean:
Frequent Visitor

## New conditionnal column in M query

Hello,

In order to add a new conditionnal column from my request, I have written a formula using M language.

I feel everything is ok and it should run well, but I have a "Jeeton Literal" waited error.

The end of my formula is a little bit tricky as I would like to write "balance" when A and B doesn't start the same way.

`= Table.AddColumn(#"Colonnes renommées1", "ABCDEF", each if ([A] = "1") then "Capitale" or if ([B] = "1") then "Capitale" else if (Text.StartsWith([A], "jj")) then "INTER" and if (Text.StartsWith([B], "jj")) then "INTER" else if (Text.StartsWith([A], "kk")) then "DOM" and if (Text.StartsWith([B], "kk")) then "DOM" else if ([A] <> [B]) then "balance" else null )`

Maybe this isn't the good place to post this, but I may need a little help.

Thanks and good evening,

Jj

1 ACCEPTED SOLUTION

Accepted Solutions
Super User I

## Re: New conditionnal column in M query

You're nesting weird extra ifs into and/or conditions. Your column's function should read

```if [A] = "1" or [B] = "1"
then "Capitale"
else if Text.StartsWith([A], "jj") and Text.StartsWith([B], "jj")
then "INTER"
else if Text.StartsWith([A], "kk") and Text.StartsWith([B], "kk")
then "DOM"
else if [A] <> [B]
then "balance"
else null```

Proud to be a Datanaut!
Super User I

## Re: New conditionnal column in M query

You're nesting weird extra ifs into and/or conditions. Your column's function should read

```if [A] = "1" or [B] = "1"
then "Capitale"
else if Text.StartsWith([A], "jj") and Text.StartsWith([B], "jj")
then "INTER"
else if Text.StartsWith([A], "kk") and Text.StartsWith([B], "kk")
then "DOM"
else if [A] <> [B]
then "balance"
else null```

Proud to be a Datanaut!

Announcements

#### Meet the 2020 Season 1 Power BI Super Users!

It’s the start of a new Super User season! Learn all about the new Super Users and brand-new tiered recognition system.

#### Super User Challenge: Can You Solve These?

We're celebrating the start of the New Super User season with our first ever Super User 'Can You Solve These?' challenge.

#### Power BI Desktop Update - February 2020

We are super excited for our update this month, as we are releasing two of our top community requests!