Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
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 @sativagate ,
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 @sativagate ,
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 @sativagate ,
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 @sativagate ,
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!