This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
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!
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |