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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
XaviOV
Helper V
Helper V

Concatenate text in different row

Hi,

 

I have a table with values that I need concatenat by number of Year-WeekOfYear. Agree a example.

Original:

AñoSemanaFiltros preparaciónÍndice
2019-S3L11
2019-S3L12
2019-S4L73
2019-S4L74
2019-S4L75
2019-S4L16
2019-S5L67
2019-S5L68

 

 

Result:

AñoSemanaFiltros preparaciónÍndiceFiltros preparación Semana
2019-S3L11 
2019-S3L22L1, L2
2019-S4L73 
2019-S4L44 
2019-S4L65 
2019-S4L16L7, L4, L6, L1
2019-S5L57 
2019-S5L68L5, L6

 

Regards,

 

Xavi

1 ACCEPTED SOLUTION
AlB
Community Champion
Community Champion

@XaviOV 

Calculated column in the first table:

Calc Column =
VAR last_ =
    CALCULATE ( MAX ( Table1[Índice] ), ALLEXCEPT ( Table1, Table1[AñoSemana] ) )
RETURN
    IF (
        Table1[Índice] = last_,
        CONCATENATEX (
            CALCULATETABLE (
                DISTINCT ( Table1[Filtros preparación] ),
                ALLEXCEPT ( Table1, Table1[AñoSemana] )
            ),
            Table1[Filtros preparación],
            ", "
        )
    )

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @XaviOV

 

Create a calculated column as below:

 

Filtros preparación Semana = 
var _maxvalue=MAXX(FILTER('Table','Table'[AñoSemana]=EARLIER('Table'[AñoSemana])),'Table'[Índice])Return
IF('Table'[Índice]=_maxvalue,CONCATENATEX(FILTER('Table','Table'[AñoSemana]=EARLIER('Table'[AñoSemana])),'Table'[Filtros preparación],","),BLANK())

 

And you will see:

Annotation 2020-06-01 180329.png

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
AlB
Community Champion
Community Champion

@XaviOV 

Calculated column in the first table:

Calc Column =
VAR last_ =
    CALCULATE ( MAX ( Table1[Índice] ), ALLEXCEPT ( Table1, Table1[AñoSemana] ) )
RETURN
    IF (
        Table1[Índice] = last_,
        CONCATENATEX (
            CALCULATETABLE (
                DISTINCT ( Table1[Filtros preparación] ),
                ALLEXCEPT ( Table1, Table1[AñoSemana] )
            ),
            Table1[Filtros preparación],
            ", "
        )
    )

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

AlB
Community Champion
Community Champion

@XaviOV 

Can also be done in the query editor

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwtNQNNlbSUfIxBBKGSrE6KIJGQMIISdAEJGgOJIzRBUGECbqgGZAwRRcEWWSGJGgKEgQR5uiCIO0WSrGxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [AñoSemana = _t, #"Filtros preparación" = _t, Índice = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"AñoSemana", type text}, {"Filtros preparación", type text}, {"Índice", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each Text.Combine(Table.SelectRows(#"Changed Type", (inner)=> inner[AñoSemana] = [AñoSemana])[Filtros preparación], ", ")),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "isLast", each if List.Max(Table.SelectRows(#"Changed Type", (inner)=> inner[AñoSemana] = [AñoSemana])[Índice]) = [Índice] then 1 else 0),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom.1", each if [isLast]=1 then [Custom] else null),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom2",{"Custom", "isLast"})
in
    #"Removed Columns"

Please mark the question solved when done and consider giving kudos if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors