Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hola a todos,
Tengo esta tabla no ordenada que está enumerando para cada contractID todo el estado de este contrato.
Notará que un estado de contrato puede estar en Terminated y luego volver a "On-Going" y que la tabla no está ordenada por año
Quiero obtener como salida PARA CADA CONTRATO la razón de estado para la última vez que el ESTADO DEL CONTRATO ha sido TERMINADO.
SO i debe obtener estos valores para el ContractID 1 y 2.
Id | Estado de la última terminación |
1 | Por elección |
2 | Jubilación |
Sé que puedo conseguirlo usando SQL con algo como esto :
LastTerminationStatus á LAST_VALUE(StatusReason) OVER (PARTITION By ID ORDER By StatusDate) Where ContractStatus á "Terminated"
Pero realmente no sé cómo conseguirlo usando DAX. He intentado LASTNONBLANK pero esta fucción requiere una tabla ordenada que no es el caso aquí
Gracias por adelantado por su ayuda !!
Solved! Go to Solution.
@anas-elkesri aquí hay dos medidas que pueden obtener el resultado
Last Terminate Reason Method 1 =
CALCULATE (
MAX ( 'Last Terminate'[Status Reason] ),
TOPN ( 1, FILTER ( ALLEXCEPT ( 'Last Terminate', 'Last Terminate'[Id] ), 'Last Terminate'[Contract Status] = "Terminated" ), [Status Date], DESC )
)
Last Terminate Reason Method 2 =
VAR __table = FILTER ( ALLEXCEPT ( 'Last Terminate', 'Last Terminate'[Id] ), 'Last Terminate'[Contract Status] = "Terminated" )
VAR __lastDate = CALCULATE ( MAX ( 'Last Terminate'[Status Date] ), __table )
RETURN
CALCULATE (
MAX ( 'Last Terminate'[Status Reason] ),
__table,
'Last Terminate'[Status Date] = __lastDate
)
Consulta mi última entrada de blog Año-2020, Pandemia, Power BI y más allá para obtener un resumen de mis versiones favoritas de las características de Power BI en 2020
Me gustaría ❤ elogios si mi solución ayudara. 👉 Si puedes dedicar tiempo a publicar la pregunta, también puedes hacer esfuerzos para dar Felicitaciones a quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!
⚡Visítenos en https://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@anas-elkesri aquí hay dos medidas que pueden obtener el resultado
Last Terminate Reason Method 1 =
CALCULATE (
MAX ( 'Last Terminate'[Status Reason] ),
TOPN ( 1, FILTER ( ALLEXCEPT ( 'Last Terminate', 'Last Terminate'[Id] ), 'Last Terminate'[Contract Status] = "Terminated" ), [Status Date], DESC )
)
Last Terminate Reason Method 2 =
VAR __table = FILTER ( ALLEXCEPT ( 'Last Terminate', 'Last Terminate'[Id] ), 'Last Terminate'[Contract Status] = "Terminated" )
VAR __lastDate = CALCULATE ( MAX ( 'Last Terminate'[Status Date] ), __table )
RETURN
CALCULATE (
MAX ( 'Last Terminate'[Status Reason] ),
__table,
'Last Terminate'[Status Date] = __lastDate
)
Consulta mi última entrada de blog Año-2020, Pandemia, Power BI y más allá para obtener un resumen de mis versiones favoritas de las características de Power BI en 2020
Me gustaría ❤ elogios si mi solución ayudara. 👉 Si puedes dedicar tiempo a publicar la pregunta, también puedes hacer esfuerzos para dar Felicitaciones a quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!
⚡Visítenos en https://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.⚡
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Muchas gracias por su respuesta.
El primer método no me dio el resultado que quería. Pero el segundo funcionó perfectamente y también es un método bastante agradable. Así que gracias de nuevo !! 🙂
@anas-elkesri , compruebe si una de las medidas puede funcionar para usted
measure: calculate(lastnonblankvalue(Table[status_date], max(Table[contract_status])))
measure: calculate(lastnonblankvalue(Table[status_date], max(Table[contract_status])) allexcept(Table[ID]))
measure- calculate(max(Table[contract_status]), filter(Table,Table[status_date] - calculate(max(Table[status_date]), allexpcept(Table,table[ID]))))
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |
User | Count |
---|---|
2 | |
2 | |
1 | |
1 | |
1 |