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
EmaVasileva
Helper V
Helper V

Extraer diferentes símbolos dentro de una columna

Hola a todos

Extraito a través de DirectQuery una columna llamada 'Comentarios'. Algunas filas de esta columna contienen texto con diferentes longitudes y símbolos. ¿Conoces alguna fórmula que pueda usar para los siguientes formatos con el fin de extraer sólo el comentario?

Comentarios (vista actual)El resultado deseado
. Emocionante.. Emocionante.
++++++++
08.00h. NNPNnp
020 John Will O'Keefe: 00:30 (2019.03.01) Trabajo O.E.Trabajo O.E.
021 Andrew Olsen: 00:45 (2020.04.05) No funciona00:45 (2020.04.05) No funciona


La transformación más necesaria es para la 4a y 5a fila- En la 4a fila solo necesito el texto después de la fecha, y en la 5a fila necesito cada uno después del signo de columna (:)

Gracias de antemano.

2 REPLIES 2
Mariusz
Community Champion
Community Champion

Hola @EmaVasileva

Pruebe a continuación o descargue el archivo pbix adjunto para obtener más información

Measure = 
VAR __comments = SELECTEDVALUE( 'Table'[Comments (current view)] )
VAR __len = LEN( __comments )
VAR __notWorking = SEARCH( "Not Working", __comments, 1, 0 ) > 0 
VAR __working = SEARCH( "Working O.E.", __comments, 1, 0 ) > 0 
VAR __NNP = SEARCH( "NNP", __comments, 1, 0 ) > 0
RETURN 
SWITCH(
    TRUE(),
    __notWorking, MID( __comments, SEARCH( ":", __comments, 1, 0 ) + 1, __len ),
    __working, "Working O.E.",
    __NNP, "NNP",
    __comments 
)

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hY9BC4JAEIX/ysNTkgzPVam8dehSoN08mKfaUpIVzKif3+5CQXToXYb3ZuYbpq4DgX4eu6kzF4FTEP1ENmyiOphb2a4vznMpZCsoir3b8sXnitgOrUHV9T3Kw51Ui53WZ52DzBNiphivhIkwDlEN49WeQikbcZwvjzcyxtqcRv1A2d+08aA0cyBFYSrMQhTD9IH5P/7PNM0L", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [#"Comments (current view)" = _t, #"The desired result" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Comments (current view)", type text}, {"The desired result", type text}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if Text.Contains([#"Comments (current view)"], "NNP ") 
            then "NNP" 
        else if Text.Contains([#"Comments (current view)"], "Working O.E.") 
            then "Working O.E." 
        else if Text.Contains([#"Comments (current view)"], "Not Working") 
            then Text.Trim(
                Text.Middle( 
                    [#"Comments (current view)"], 
                    Text.PositionOf( [#"Comments (current view)"], ":"  ) + 1 
                )
            )
            
        else [#"Comments (current view)"])
    
in
    #"Added Conditional Column"

Como está trabajando con Direct Query, es posible que ambos no funcionen, por lo que insertar este cálculo en el origen de datos podría ser una opción.

Saludos
Mariusz

Si este post ayuda,entonces por favor considere aceptarlo como la solución.

Por favor, siéntase libre de conectarse conmigo.
Linkedin

Hola @Mariusz

Disculpas por mi respuesta tardía y gracias por la ayuda. Ninguna de las soluciones funciona en modo DirectQuery y como solución final importé la tabla necesaria y utilicé la segunda fórmula.

Aceptaré su puesto como solución. 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.