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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.