Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
Anonymous
Not applicable

Medida, anidado-IF, texto

Hola a todos los gurús de DAX,

source_table:

Ubicación (texto)Fase (texto)

Id (número)

Valor (número)
AP1110
BP1210
BP2310
CP2410
CP35

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ónFaseIdnew_measure
AP1110
BP1210
CP2410

Intenté usar RANKX, KEEPFILTER, ISFILTERED, pero así que har no ha tenido éxito.

Gracias de antemano 🙂

1 ACCEPTED 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.

View solution in original post

6 REPLIES 6
v-eachen-msft
Community Support
Community Support

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.

2-1.PNG

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Anonymous
Not applicable

@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.

parry2k
Super User
Super User

@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.

Anonymous
Not applicable

@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.

Anonymous
Not applicable

@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!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.