Forum Discussion

jemalosa's avatar
jemalosa
Frequent Visitor
4 years ago
Solved

Cadena de texto

Buenos días,

 

A ver si alguien me puede ayudar:

 

Tengo dos tablas:

Tabla 1

Nombre
glusterblock-storage-provisioner-dc-1-3rg3j4
busqueda-ms-002-5
commercial-settlementpayments-2-00er4
drupal-cms-asyb-21-02

 

Tabla 2

NombreValor
glusterblock-storage-provisioner-dc123
busqueda-ms45
commercial-settlementpayments33
drupal-cms-asyb54

 


Necesitaría traer el valor de la tabla 2 a la tabla 1 y para ello la función DAX debería recorrer el texto de la tabla 2 hasta que coincidiera con el texto de la tabla 1. La teoría la sé pero no logro llevarlo a una sentencia DAX. 
Como se ve, no siguen un patrón en el que pueda hacer un split por "-".

 

He probado con la siguiente sentencia pero no ajusta la búsqueda al 100%:

 

Valor = VAR TextbeforeQM =
LEFT(
'Tabla 1'[Nombre],
VAR mylen1 =
FIND ( "-", 'Tabla 1'[Nombre], 1, 0 )
RETURN
IF ( mylen1 = 0, LEN ( 'Tabla 1'[Nombre] ), mylen1 - 1 )
)
RETURN
LOOKUPVALUE (Tabla 2 [Valor] ,Tabla 2 [Nombre], TextbeforeQM )
 
¿alguna idea por favor?
 
Un saludo y gracias de entemano
 
  • The solution was much simpler than the way I was putting it. I was fixated on DAX when there is a function from power query that solves the problem.
    It is Table.FuzzyNestedJoin...

4 Replies

  • jemalosa , something like this

     

    Valor = VAR TextbeforeQM =
    LEFT(
    'Tabla 1'[Nombre],
    VAR mylen1 =
    FIND ( "-", 'Tabla 1'[Nombre], 1, 0 )
    RETURN
    IF ( mylen1 = 0, LEN ( 'Tabla 1'[Nombre] ), mylen1 - 1 )
    )
    RETURN
    maxx (filter('Tabla 2', 'Tabla 2' [Nombre]= TextbeforeQM ),'Tabla 2' [Valor])

     

     

    what is expected output

    • jemalosa's avatar
      jemalosa
      Frequent Visitor

      Hello amitchandak,

       

      Thank you for your help,

      I have tried your solution and it brings me the same values as with the solution I had already tried.

      There are certain text strings that do not bring me the value.

      Any ideas?

       

       

      Tabla 1Valor
      challenges-compromises-batch-7-d25lg 
      challenges-compromises-9-tpq55 
      challenges-compromises-9-x8jvx 

       

      Tabla 2Valor
      challenges-compromises2
      challenges-compromises-batch1

       

      Regards

    • jemalosa's avatar
      jemalosa
      Frequent Visitor

      I will try to explain it better:

      I have a table with thousands of rows similar to:

      Table 1
      alertmanager-main-0-rdes34
      alertmanager-main-1
      alertmanager-main-2-234r
      apa-app-9-vr6
      apa-app-4
      cluster-events-kafka-11
      cluster-events-kafka-2-23t5

      I have another table similar to this one containing a value field:

       

      Table 2                                    Value
      alertmanager-main                   3
      apa-app                                    1
      cluster-events-kafka                 1


      I need to find the values of table 2 in table 1. For row 1,2 and 3 in Table 1 the value would be "3".
      For rows 4 and 5 the value would be "1" and for rows 6 and 7 the value would be "1".

      As you can see, the names in Table 1 do not have an equal pattern, since they can have 1 or two hyphens.

      How could I do a search so that when I match the name of table 2 with the common part of the name of table 1 I can find the value?

      Best regards

      • jemalosa's avatar
        jemalosa
        Frequent Visitor

        The solution was much simpler than the way I was putting it. I was fixated on DAX when there is a function from power query that solves the problem.
        It is Table.FuzzyNestedJoin...