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

Cómo utilizar una variable de cadena dinámica

Hola, chicos

Espero que puedas ayudarme, tengo esta tabla:

edgarcalgary_0-1595963928484.png

los datos no siempre están ordenados por lo que, estoy buscando el nombre del operador donde el id es el más alto: esto el siguiente i fue capaz de obtener el nombre del operador por max wellid,

_CURRENT = 
VAR TOPWELL = MAX('Well List'[WellID])
VAR _topclient = 
CALCULATE(MAX('Well List'[Operator]), KEEPFILTERS( FILTER( ALL('Well List'[WellName], 'Well List'[Operator], 'Well List'[WellID]), 'Well List'[WellID] = TOPWELL)))
return _topclient

edgarcalgary_1-1595964212129.png

¿cómo puedo identificar en la tabla principal a todos los operadores con el nombre como resultado de la medida? Lo intenté:

IF( _topclient IN VALUES(Operator name), 1, 0)

pero esto devuelve todos los valores como 1. ¿Alguna idea?

1 ACCEPTED SOLUTION

Hola @edgarcalgary ,

Por favor, intente crear una columna calculada con la siguiente fórmula para reemplazar la medida original:

Column = 
VAR _topclient =
    CALCULATE (
        MAX ( 'Well List'[Operator] ),
        FILTER (
            ALL ( 'Well List' ),
            'Well List'[WellID] = MAX ( 'Well List'[WellID] )
        )
    )
RETURN
    IF (  'Well List'[Operator]  = _topclient, 1, 0 )

How to use a dynamic string variable_calculated column.JPG

Saludos

Rena

View solution in original post

11 REPLIES 11
Ashish_Mathur
Super User
Super User

Hola

Comparte el enlace desde donde puedo descargar tu archivo PBI.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Greg_Deckler
Super User
Super User

@edgarcalgary - No estoy seguro de entender completamente, pero tal vez esto:

Medidas: IF(MAX([Operador]) - [_CURRENT],1,0)


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

si sólo devuelvo la variable _topclient:

_CURRENT = 
VAR TOPWELL = MAX('Well List'[WellID])
VAR _topclient = 
CALCULATE(MAX('Well List'[Operator]), KEEPFILTERS( FILTER( ALL('Well List'[WellName], 'Well List'[Operator], 'Well List'[WellID]), 'Well List'[WellID] = TOPWELL)))
return _topclient

el resultado es el siguiente:

edgarcalgary_0-1595966754803.png

por lo que parece que está filtrando fila por fila y no dando el resultado adecuado.

@edgarcalgary - Todavía estoy 100% claro, pero es posible que necesite un ALL o ALLEXCEPT allí para salir del contexto actual de la imagen / fila.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

¿Alguna idea de dónde debo aplicarlo?

Hola @edgarcalgary ,

Por favor, intente actualizar la fórmula de medida como se muestra a continuación:

Flag =
VAR TOPWELL =
    CALCULATE ( MAX ( 'Well List'[WellID] ), ALL ( 'Well List' ) )
VAR _topclient =
    CALCULATE ( MAX ( 'Well List'[Operator] ), 'Well List'[WellID] = TOPWELL )
RETURN
    IF ( MAX ( 'Well List'[Operator] ) = _topclient, 1, 0 )

How to use a dynamic string variable.JPG

Saludos

Rena

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

Hola @yingyinr ,

Gracias por su respuesta, ya lo intenté de esa manera antes con el resultado, pero, veo en su ejemplo que tiene dos "JJ", así que básicamente ¿ cómo agregaría el valor 1 en todos los JJ en la columna?

Hola @edgarcalgary ,

Por favor, intente crear una columna calculada con la siguiente fórmula para reemplazar la medida original:

Column = 
VAR _topclient =
    CALCULATE (
        MAX ( 'Well List'[Operator] ),
        FILTER (
            ALL ( 'Well List' ),
            'Well List'[WellID] = MAX ( 'Well List'[WellID] )
        )
    )
RETURN
    IF (  'Well List'[Operator]  = _topclient, 1, 0 )

How to use a dynamic string variable_calculated column.JPG

Saludos

Rena

@yingyinr No entiendo por qué todos estamos después de crear la columna cuando measure puede hacer el trabajo. ¿Entendemos la diferencia entre crear medida frente a columnas y cómo tiene un impacto en el modelo?



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.

@edgarcalgary @yingyinr solución debería funcionar, no estoy seguro de por qué no muestra 1 para cada operador de JJ, creé datos de muestra y utilicé la siguiente medida

Top Operator = 
VAR __topId = CALCULATE ( MAX ( Well[Id] ), ALL (  Well ) )
VAR __topOpertor = CALCULATE ( MAX ( Well[Operator] ), Well[Id] = __topId )
RETURN IF ( MAX ( Well[Operator] ) = __topOpertor, 1, 0 )

Me gustaría elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos enhttps://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.

Anonymous
Not applicable

Hola @Greg_Deckler ,

Gracias por su respuesta, todavía tengo el mismo resultado que 1, sé que Max va a interviar fila por fila, pero preguntándome por qué no reconocer la variable _topclient.

edgarcalgary_0-1595966589654.png

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.