Forum Discussion
power query
- 4 years ago
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
- 4 years ago
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
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
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é.