skopcak
¿Sería posible hacer esto en el editor de consultas?
Cantidad | Código | Código 2 | resultado |
1 | 1a | 4/17 | 1a (4/17) |
2 | 2b | 4/17 | 2b (4/17) |
1 | 3c | 4/17 | 2b (4/17) |
3 | 4d | 4/17 | 3c (4/17) |
3 | 5e | 4/17 | 4d (4/17) |
3 | 6f | 4/17 | 4d (4/17) |
4d (4/17) | |||
5e (4/17) | |||
5e (4/17) | |||
5e (4/17) | |||
6f (4/17) | |||
6f (4/17) | |||
6f (4/17) |
gracias respuesta
Anónimo
En respuesta a v-ljerr-msft
Aquí hay un enfoque que podría estar cerca…
Crea una función «NewList»:
(Quantity, Code, Code2) =>
let
NewList = List.Generate(()=>
// Start your counter at 0 and seed your list "Result" with your required values
[QtyCntr = 0, Result = {Code & " (" & Code2 & ")"}],
// As you increment the counter to the limit of Quantity, build up another value set
each [QtyCntr] < Quantity, each [QtyCntr=[QtyCntr]+1, Result = {Code & " (" & Code2 & ")"}],
//Return each value set (one for each Quantity)
each [Result])
in
NewList
Cree una Table2 para hacer referencia a su fuente Table1, llame a la función para cada fila y expanda las listas de listas:
let Source = Table1, #"Added Custom" = Table.AddColumn(Source, "Custom", each NewList([Quantity],[Code],[Code 2])), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Expanded Custom1" = Table.ExpandListColumn(#"Expanded Custom", "Custom") in #"Expanded Custom1"
Luego ordene sus columnas según sea necesario…
v-ljerr-msft
Hola @skopcak,
Al principio, pensé que esto podría lograrse usando algunas funciones de tabla (M) como Table.SelectRows y Table.Repeat, etc. Y lo he intentado mucho, pero aún no puedo resolverlo (estoy tratando de estudiar M actualmente). @ImkeF, ¿podría ayudarnos?
Saludos
Anónimo
En respuesta a v-ljerr-msft
Aquí hay un enfoque que podría estar cerca…
Crea una función «NewList»:
(Quantity, Code, Code2) =>
let
NewList = List.Generate(()=>
// Start your counter at 0 and seed your list "Result" with your required values
[QtyCntr = 0, Result = {Code & " (" & Code2 & ")"}],
// As you increment the counter to the limit of Quantity, build up another value set
each [QtyCntr] < Quantity, each [QtyCntr=[QtyCntr]+1, Result = {Code & " (" & Code2 & ")"}],
//Return each value set (one for each Quantity)
each [Result])
in
NewList
Cree una Table2 para hacer referencia a su fuente Table1, llame a la función para cada fila y expanda las listas de listas:
let Source = Table1, #"Added Custom" = Table.AddColumn(Source, "Custom", each NewList([Quantity],[Code],[Code 2])), #"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"), #"Expanded Custom1" = Table.ExpandListColumn(#"Expanded Custom", "Custom") in #"Expanded Custom1"
Luego ordene sus columnas según sea necesario…
skopcak
En respuesta a Anónimo
Hola, gracias por su respuesta, funciona muy bien. Estoy muy agradecido.
skopcak
por bylo možné v dotazu editor, jak to udělat?
Množství | Kod | cod 2 | výsledek |
1 | 1a | 4/17 | 1a (4/17) |
2 | 2b | 4/17 | 2b (4/17) |
1 | 3c | 4/17 | 2b (4/17) |
3 | 4d | 4/17 | 3c (4/17) |
3 | 5e | 4/17 | 4d (4/17) |
3 | 6f | 4/17 | 4d (4/17) |
4d (4/17) | |||
5e (4/17) | |||
5e (4/17) | |||
5e (4/17) | |||
6f (4/17) | |||
6f (4/17) | |||
6f (4/17) |
Děkujeme, že jste odpověď