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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
mablazquez
Regular Visitor

Columna calculada a partir de datos de otras columnas

Buenos días a tod@s!!

 

Necesito vuestra ayuda estoy atascado y no consigo dar con la solución.

 

Tengo estos datos de ejemplo:

image.png

 

Si la columna Resumen contien la cadena #agrupa entonces todos los Proyectos con el mismo número tendrán el mismo Nombre de Aplicación.

El resultado tiene que ser el de la columna Nombre Aplicación Agrupado.

Muchas gracias de antemano,

 

Miguel Ángel

2 ACCEPTED SOLUTIONS
Payeras_BI
Super User
Super User

Hola @mablazquez,

In Power Query could be done like this:

Payeras_BI_0-1652777172923.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fdE9DsIwDIbhq1Rh7RDnx0lHVqaKteoQKoQqQakq9WQcoRcjE7IZvs2SHy9+h8Es79dtuzdkWtNfL9Z6Yq7zeX3OU5nm47PU3dj+oAPQSegB9BIGAIOEEcAoIQPIEiYAk4S5OZXHtq8FHGR50AHYSUgWfd4qKiLl/E9VJXKIqk7kEVWlKCCqWlFEVNUiRlT1ooRoLTZ+AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Resumen = _t, Proyecto = _t, #"Nombre Aplicación" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Resumen", type text}, {"Proyecto", type text}, {"Nombre Aplicación", type text}}),
    #"Contains #agrupa" = Table.SelectRows(#"Changed Type", each Text.Contains([Resumen], "#agrupa")),
    Custom1 = #"Changed Type",
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Proyecto"}, #"Contains #agrupa", {"Proyecto"}, "Custom", JoinKind.LeftOuter),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Merged Queries", "Custom", {"Nombre Aplicación"}, {"Nombre Aplicación Agrupado"}),
    #"Replaced Value" = Table.ReplaceValue(#"Expanded Custom",null,each [Nombre Aplicación],Replacer.ReplaceValue,{"Nombre Aplicación Agrupado"})
in
    #"Replaced Value"

 

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

Hola de nuevo @mablazquez,

Te paso también una posible solución como columna calculada de DAX:

 

DAX Solution =
VAR _Proyecto = 'Table DAX'[Proyecto]
VAR _NApli = 'Table DAX'[Nombre Aplicación]
VAR _Agrupa =
    CALCULATETABLE (
        VALUES ( 'Table DAX'[Nombre Aplicación] ),
        CONTAINSSTRING ( 'Table DAX'[Resumen], "#agrupa" ),
        'Table DAX'[Proyecto] = _Proyecto,
        REMOVEFILTERS ()
    )
RETURN
    IF ( NOT ISBLANK ( _Agrupa ), _Agrupa, _NApli )

 

Payeras_BI_0-1652786642501.png

Espero que te sea de ayuda.

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

View solution in original post

5 REPLIES 5
Payeras_BI
Super User
Super User

Hola @mablazquez ,

Gracias por tu comentario. 😊

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain
mablazquez
Regular Visitor

Gracias J. Payeras!! me sirve como solución, aunque no controlo demasiado Power Query. 

 

Me gustaría conocer también la solución en DAX si es posible!! Gracias!

Hola de nuevo @mablazquez,

Te paso también una posible solución como columna calculada de DAX:

 

DAX Solution =
VAR _Proyecto = 'Table DAX'[Proyecto]
VAR _NApli = 'Table DAX'[Nombre Aplicación]
VAR _Agrupa =
    CALCULATETABLE (
        VALUES ( 'Table DAX'[Nombre Aplicación] ),
        CONTAINSSTRING ( 'Table DAX'[Resumen], "#agrupa" ),
        'Table DAX'[Proyecto] = _Proyecto,
        REMOVEFILTERS ()
    )
RETURN
    IF ( NOT ISBLANK ( _Agrupa ), _Agrupa, _NApli )

 

Payeras_BI_0-1652786642501.png

Espero que te sea de ayuda.

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

Muchísimas gracias!!!

Es exactamente lo que buscaba en DAX.

También pongo tu respuesta como resuelta.

Gracias! de verdad!!

Payeras_BI
Super User
Super User

Hola @mablazquez,

In Power Query could be done like this:

Payeras_BI_0-1652777172923.png

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fdE9DsIwDIbhq1Rh7RDnx0lHVqaKteoQKoQqQakq9WQcoRcjE7IZvs2SHy9+h8Es79dtuzdkWtNfL9Z6Yq7zeX3OU5nm47PU3dj+oAPQSegB9BIGAIOEEcAoIQPIEiYAk4S5OZXHtq8FHGR50AHYSUgWfd4qKiLl/E9VJXKIqk7kEVWlKCCqWlFEVNUiRlT1ooRoLTZ+AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Resumen = _t, Proyecto = _t, #"Nombre Aplicación" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Resumen", type text}, {"Proyecto", type text}, {"Nombre Aplicación", type text}}),
    #"Contains #agrupa" = Table.SelectRows(#"Changed Type", each Text.Contains([Resumen], "#agrupa")),
    Custom1 = #"Changed Type",
    #"Merged Queries" = Table.NestedJoin(#"Changed Type", {"Proyecto"}, #"Contains #agrupa", {"Proyecto"}, "Custom", JoinKind.LeftOuter),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Merged Queries", "Custom", {"Nombre Aplicación"}, {"Nombre Aplicación Agrupado"}),
    #"Replaced Value" = Table.ReplaceValue(#"Expanded Custom",null,each [Nombre Aplicación],Replacer.ReplaceValue,{"Nombre Aplicación Agrupado"})
in
    #"Replaced Value"

 

 

If this post answered your question, please mark it as a solution to help other users find useful content.
Kudos are another nice way to acknowledge those who tried to help you.

J. Payeras
Mallorca, Spain

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors