Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Joak
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
KHorseman
Community Champion
Community Champion

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




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

1 REPLY 1
KHorseman
Community Champion
Community Champion

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




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.