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 los gurús de DAX,
source_table:
Ubicación (texto) | Fase (texto) | Id (número) | Valor (número) |
A | P1 | 1 | 10 |
B | P1 | 2 | 10 |
B | P2 | 3 | 10 |
C | P2 | 4 | 10 |
C | P3 | 5 | 10 |
Lógica:
Para cada ubicación:
si la Fase- P1, calculada (Valor; FILTRO (Source_table; Fase - P1));
si la Fase- P2, se calcula (Valor; FILTRO (Source_table; Fase - P2));
si la Fase- P3, calculada (Valor; FILTRO (Source_table; Fase - P3));
Explicación:
Para cada ubicación, si hay un valor P1, devuelva el valor P1.
Si no hay ningún valor P1, utilice el valor P2.
Si no hay ningún valor P2, utilice el valor P3.
¿Cómo puedo lograr una tabla de resultados como la siguiente, con la lógica anterior, utilizando sólo la medida? Utilizo el modelo SAAS, por lo que solo puedo crear una nueva medida (sin columnas calculadas).
Result_table:
Ubicación | Fase | Id | new_measure |
A | P1 | 1 | 10 |
B | P1 | 2 | 10 |
C | P2 | 4 | 10 |
Intenté usar RANKX, KEEPFILTER, ISFILTERED, pero así que har no ha tenido éxito.
Gracias de antemano 🙂
Solved! Go to Solution.
@savvyt probar esto
Measure =
VAR __p1 = CALCULATE ( [Value Measure], Table[Phase] = "P1" )
VAR __p2 = CALCULATE ( [Value Measure], Table[Phase] = "P3" )
VAR __p3 = CALCULATE ( [Value Measure], Table[Phase] = "P3" )
RETURN
SWITCH ( TRUE(),
__p1 <> BLANK(), __p1,
__p2 <> BLANK(), __p2,
__p3
)
Me gustaría❤ elogiossi mi solución me ayudó.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para darle a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!
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.
Hola @savvyt ,
Si su tabla de hechos tiene el mismo orden que el ejemplo, podría probar el siguiente DAX:
Measure =
IF (
SELECTEDVALUE ( 'Table'[Id] )
= CALCULATE ( MIN ( 'Table'[Id] ), ALLEXCEPT ( 'Table', 'Table'[Location] ) ),
[Your value]
)
Aquí está el resultado.
@v-eachen-msft gracias por la ayuda, pero el ID es aleatorio por desgracia, así que no puedo usar MIN. Todavía estoy tratando de entender por qué obtengo toda la Fase en la tabla de resultados.
@savvyt realmente no está seguro de lo que significa esto:
Para cada ubicación:
si la Fase- P1, obtenga Valor;
si la Fase- P2, obtener Valor ; Value
de lo contrario si la Fase- P3, obtener valor
todos están obteniendo valor?
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.
@parry2k Agregué una explicación al problema anterior. Lo siento si no estaba claro.
@savvyt probar esto
Measure =
VAR __p1 = CALCULATE ( [Value Measure], Table[Phase] = "P1" )
VAR __p2 = CALCULATE ( [Value Measure], Table[Phase] = "P3" )
VAR __p3 = CALCULATE ( [Value Measure], Table[Phase] = "P3" )
RETURN
SWITCH ( TRUE(),
__p1 <> BLANK(), __p1,
__p2 <> BLANK(), __p2,
__p3
)
Me gustaría❤ elogiossi mi solución me ayudó.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para darle a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!
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.
@parry2k el result_table es correcto si solo tiene columnas de ubicación, id.y new_measure, pero cuando agregué la columna De fase, se desordenó y mostró la ubicación duplicada, new_measure valor para toda la fase P1-P3. ¿Cómo puedo evitar esto? ¡gracias!
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 |