Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
Hola a todos
Tengo la siguiente tabla:
D2_DOCD2_CLIENTED2_CODF2_EMISSAOAnoEmissao
000015387 | 000133 | SEÑAL SF2 | 08/02/2017 | 2017 |
000018277 | 000133 | SEÑAL SF2 | 22/03/2018 | 2018 |
000027346 | 000133 | SEÑAL SF2 | 10/11/2020 | 2020 |
000031179 | 000133 | SEÑAL SF2 | 23/11/2021 | 2021 |
000031840 | 000133 | SEÑAL SF3 | 28/02/2022 | 2022 |
000035941 | 000133 | SEÑAL SF3 | 17/04/2023 | 2023 |
Me gustaría contar el número de años consecutivos a partir del año actual (2023), por ejemplo, en el conjunto de datos la medida DAX debe devolver el valor = 4, refiriéndose a los años 2023, 2022, 2021 y 2020.
Basándome en su descripción, creé datos para reproducir su escenario. El archivo pbix se adjunta al final.
en DAX
¿Por qué debería ser una medida DAX? ¿Cómo puede esto verse afectado por las acciones del usuario?
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dc89CsMwDAXgqxTPAes9ObUydgkUSpaMwfe/RqzY/RlqLXoIfQgdR5BamNVymDxDtYb9uT1et32lDy0KIwW+cbUydWbMQ0ZGUWfWmH0Ys6b7iEEiUBnlYrW9mQJ5GV7TztAYfpgl+cc8s/9GNsYvm5eEEUOOkpxpYxpKOQE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Doc = _t, Client = _t, Code = _t, Date = _t, Year = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Doc", Int64.Type}, {"Client", Int64.Type}, {"Code", type text}, {"Date", type text}, {"Year", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1, Int64.Type),
#"Added Custom" = Table.AddColumn(#"Added Index", "Consecutive", each List.Accumulate({0..[Index]},1,(state,current)=> if current = 0 then state else if #"Added Index"{current}[Year]=#"Added Index"{current-1}[Year]+1 then state+1 else 1))
in
#"Added Custom"
Cómo usar este código: Crear una nueva consulta en blanco. Haga clic en "Editor avanzado". Reemplace el código en la ventana con el código proporcionado aquí. Haga clic en "Listo".
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the June 2024 Power BI update to learn about new features.