Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowData Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more
Bonjour
J'ai un probleme a le code M je ne suis pas doué pour les Expression de language M ,mais
de base le code est sencé faire et remplacé ma formule dans la colonne E Celule E2 a E40
SI.CONDITIONS(GAUCHE($D2;3)="sol";"SOL";GAUCHE($D2;3)="PAP";"PAP";$D2>0;"GARE");"")
dans un exemple de donné comme suite. sachant que la colonne Emplacemnt est variable.
| Emplacement | résultat |
| 9 | GARE |
| sol15 | SOL |
| BOUILLE | BOUILLE |
Le langage suivant comporte une erreur, je ne sais pas sur quel paramètre
Bonjour
J'ai un probleme a le code M je ne suis pas doué pour les Expression de language M ,mais
de base le code est sencé faire et remplacé ma formule dans la colonne E Celule E2 a E40
SI.CONDITIONS(GAUCHE($D2;3)="sol";"SOL";GAUCHE($D2;3)="PAP";"PAP";$D2>0;"GARE");"")
dans un exemple de donné comme suite.
| un | b | c | D : Emploi | E:résultat |
| 9 | GARE | |||
| sol15 | SOL | |||
| BOUILLE | BOUILLE |
Solved! Go to Solution.
Hi @Anonymous ,
In M code, it would be something like this:
if Text.Start(Text.Lower([Emplacement]), 3) = "sol" then "SOL"
else if Text.Start(Text.Lower([Emplacement]), 3) = "pap" then "PAP"
else if Number.From([Emplacement]) > 0 then "GARE"
else [Emplacement]
Note that M is completely case sensitive, so I've used "Text.Lower" functions to correct this before the evaluation of these conditions.
Pete
Proud to be a Datanaut!
Hi @Anonymous ,
Try this instead:
try
if Text.Contains([Emplacement], Character.FromNumber(38)) then "GARE" //38 is "&" Unicode character
else if Text.Start(Text.Lower([Emplacement]), 3) = "sol" then "SOL"
else if Text.Start(Text.Lower([Emplacement]), 3) = "pap" then "PAP"
else if Number.From([Emplacement]) > 0 then "GARE"
else [Emplacement]
otherwise [Emplacement]
The Character.FromNumber(38) picks out any values that contain "&", and the try...otherwise block escapes any further errors.
Pete
Proud to be a Datanaut!
Bonjour BA_Pete
Merci beaucoup de votre réponse j'aime cette solution très simple .
Vous est admirable , et sa fonctionne super bien sauf pour les deux
par contre quand j'ai une ligne comme exemple si dessous :
8 et 9 = erreur
8 & 9 = erreur
sinon si Text.Contains ([GARE]) = "&" then "GARE"
Merci encor de votre générosité et de votre aide.
cordialement
Hi @Anonymous ,
Try this instead:
try
if Text.Contains([Emplacement], Character.FromNumber(38)) then "GARE" //38 is "&" Unicode character
else if Text.Start(Text.Lower([Emplacement]), 3) = "sol" then "SOL"
else if Text.Start(Text.Lower([Emplacement]), 3) = "pap" then "PAP"
else if Number.From([Emplacement]) > 0 then "GARE"
else [Emplacement]
otherwise [Emplacement]
The Character.FromNumber(38) picks out any values that contain "&", and the try...otherwise block escapes any further errors.
Pete
Proud to be a Datanaut!
Bonjour BA_Pete
Merci encore, mais malheureusement cela ne fonctionne pas.
Cette ligne me donne une erreur de DataFormat.Error.
if Text.Contains([GARE],Character.FromNumber(38)) then "GARE"
Alors j'ai contourné le problème en utilisant la correction d'erreur.
#"Erreurs prolongées" = Table.ReplaceErrorValues(#"Lignes filtrées", {{"gareN", "GARE"}})
in
#"Erreurs prolongées"
Je vous remercie beaucoup pour m'avoir aidé.
Hi @Anonymous ,
In M code, it would be something like this:
if Text.Start(Text.Lower([Emplacement]), 3) = "sol" then "SOL"
else if Text.Start(Text.Lower([Emplacement]), 3) = "pap" then "PAP"
else if Number.From([Emplacement]) > 0 then "GARE"
else [Emplacement]
Note that M is completely case sensitive, so I've used "Text.Lower" functions to correct this before the evaluation of these conditions.
Pete
Proud to be a Datanaut!
Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.
Check out the May 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 3 | |
| 2 | |
| 1 |
| User | Count |
|---|---|
| 11 | |
| 11 | |
| 5 | |
| 4 | |
| 3 |