Forum Discussion
indefinido
- 5 years ago
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"
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_Admin5 years ago
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_Admin5 years ago
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" - Syndicate_Admin5 years ago
Administrator
No @Bokchoy,
Para su alquiler, puede usar el valor de índice actual como condición para filtrar registros de tabla y extraer y resumer valores de campo lstradingday. (usted puede referirse a lbendlin 's formuals)
En mi opinión, creo que las funciones dax deberían ser más adecuadas para estos cálculos, la consulta M puede gastar más recursos para estos cálculos de bucle. Puede intentar agregar funciones de búfer para reducir los gastos de recursos adicionales.
Funciones anidadas y Table.Buffer() - Exceed
SaludosXiaoxin Sheng