Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
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!
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 11 | |
| 10 | |
| 8 | |
| 7 | |
| 6 |