Forum Discussion
DanielAravenaL
3 years agoNew Member
SQL function to M
Hi, I'm new with Power Query language, and I'm stuck with a SQL function. I cannot convert it ALTER FUNCTION [dbo].[funcion_CalculaDigitoRut]
(
Rut int
)
RETURNS char(2)
AS
BE...
- 3 years ago
fRutDV=(Rut as number,optional Contador as number,optional Acumulador as number) => let xContador =Contador??2, xAcumulador =Acumulador??0, Digito= 11-Number.Mod(xAcumulador,11) in if Rut = 0 then if Digito=10 then "K" else if Digito=11 then "0" else Text.From(Digito) else @fRutDV(Number.Round(Rut/10),if xContador>6 then 2 else xContador+1,xAcumulador + Number.Mod(Rut,10) * xContador)
wdx223_Daniel
3 years agoCommunity Champion
fRutDV=(Rut as number,optional Contador as number,optional Acumulador as number) =>
let
xContador =Contador??2,
xAcumulador =Acumulador??0,
Digito= 11-Number.Mod(xAcumulador,11)
in
if Rut = 0 then
if Digito=10 then "K"
else if Digito=11 then "0"
else Text.From(Digito)
else @fRutDV(Number.Round(Rut/10),if xContador>6 then 2 else xContador+1,xAcumulador + Number.Mod(Rut,10) * xContador)