Forum Discussion
indefinido
Hola a todos
im tratando de crear una nueva columna en mi tabla donde sólo las filas de índice que tienen [Istradingday] = 1.
Im tratando de archieve esto escribiendo un bucle de fucntion personalizado invocado se muestra a continuación:
El resultado actual de la columna personalizada tiene este aspecto:
Nunca he usado M lanuage antes y necesito ayuda con los siguientes problemas:
1. Cuando [istradingday] = 0, quiero mostrar en blanco. (actualmente mostrando "X")
2. Valor + 1 sólo cuando [istradingday] = 1. (actualmente será + 1 para cada bucle independientemente]
pregunta lateral: ¿hay una manera de escribir bucles for /while en M lanuage simuliar a python
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3sNA3MjAyVNJRMgDi4NK8lMRKIAMkoKAUqxOtZGCEpAaEffPzgKQRmAdWYIymIKQ0tRhIGYNVgVWYoKkIT00BkiZgRWAFpuhGZJQWASlTsCqwCjM0FW5FmUDSDKwIrMAc3SuJJUDSHOKPWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Istradingday = _t, Day = _t, Index = _t, #"Istradingindex (Desired outcome)" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Istradingday", Int64.Type}, {"Index", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "IsTradeIndex", each if [Istradingday]=0 then "" else List.Sum(Table.FirstN(#"Changed Type",[Index])[Istradingday])) in #"Added Custom"
4 Replies
- Syndicate_Admin
Administrator
M ha incorporado funciones de iteración ("cada" ) y también admite bucles a través de List.Generate().
Por favor, proporcione datos de muestra en formato utilizable (no como una imagen - tal vez insertar en una tabla?) y mostrar el resultado esperado.
- Syndicate_Admin
Administrator
Hola, gracias por responder a mi pregunta, por favor vea los datos adjuntos por ejemplo para 1 semana.
Tabla actualFecha Istradingday Día Índice Istradingindex (resultado deseado) 1/08/2021 0 Domingo 1 02/08/2021 1 Mi 2 1 03/08/2021 1 Martes 3 2 04/08/2021 1 Miércoles 4 3 05/08/2021 1 Thur 5 4 06/08/2021 1 Vie 6 5 07/08/2021 0 Sábado 7 ... ... ... ... ... - Syndicate_Admin
Administrator
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ3sNA3MjAyVNJRMgDi4NK8lMRKIAMkoKAUqxOtZGCEpAaEffPzgKQRmAdWYIymIKQ0tRhIGYNVgVWYoKkIT00BkiZgRWAFpuhGZJQWASlTsCqwCjM0FW5FmUDSDKwIrMAc3SuJJUDSHOKPWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Istradingday = _t, Day = _t, Index = _t, #"Istradingindex (Desired outcome)" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Istradingday", Int64.Type}, {"Index", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "IsTradeIndex", each if [Istradingday]=0 then "" else List.Sum(Table.FirstN(#"Changed Type",[Index])[Istradingday])) in #"Added Custom"