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

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

Reply
Nivas538
Microsoft Employee
Microsoft Employee

Combine values of multiple rows in one row and excluding one row based on condition

Hi Team,

 

I got the all the rows into onerow (Comma seperated values) but didn't understand how to exclude islatest=1 condition in the output column

 

Currently I'm using this M Query:
#"Grouped Rows" = Table.Group(#"Changed Type1", {"Name"}, {{"Count", each _, type table [Alias=text, IsLatest=number, RegEventName=text, Index=number]}}),
#"Added Custom3" = Table.AddColumn(#"Grouped Rows", "Custom", each Table.AddIndexColumn([Count],"ind",1,1)),
#"Added Custom4" = Table.AddColumn(#"Added Custom3", "Custom.1", each Table.Column([Count],"EventName")),
#"Extracted Values" = Table.TransformColumns(#"Added Custom4", {"Custom.1", each Text.Combine(List.Transform(_, Text.From), ","), type text}),

 

Output which i am getting : (But need to exclude Islatest event from the output colum(OtherEvents))

Name Other Events
bDec,Mar
bDec,Mar
cDec
dMar
aDec,Mar,Nov,May
aDec,Mar,Nov,May
aDec,Mar,Nov,May
aDec,Mar,Nov,May

 

Can you please help me out?

 

 

Input Data:

Input
NameEventNameEdateSdateIslatest
bDec18-12-201912-12-20190
bMar17-03-202013-03-20201
cDec18-12-201912-12-20191
dMar17-03-202013-03-20201
aMay18-05-202014-05-20201
aNov18-11-201911-11-20190
aMar17-03-202013-03-20200
aDec18-12-201912-12-20190
     

 

Required Output:

 

 

OutPut
Name Other Events
bDec
bDec
c 
d 
aDec,Mar,Nov
aDec,Mar,Nov
aDec,Mar,Nov
aDec,Mar,Nov

 

Thanks In Advance,

 

Regards

Sri.

 

 

1 ACCEPTED SOLUTION
ImkeF
Community Champion
Community Champion

Hi @Nivas538 

you can do without the index like so:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlLSUXJJTQaShhb6hkb6RgaGliCOERLHQClWB6LSN7EIJGmub2AMlDQyAHGMkTlglclEmAlRmUK0mYlglZUQMw1M4ZImyBy4Sr/8MqjthnALDZE4Bkhm4rcdoZKIUIoFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, EventName = _t, Edate = _t, Sdate = _t, Islatest = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"EventName", type text}, {"Edate", type date}, {"Sdate", type date}, {"Islatest", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Name"}, {{"All", each _}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Text.Combine(Table.SelectRows([All], (x)=> x[Islatest]=0)[EventName], ", ")),
    #"Expanded All" = Table.ExpandTableColumn(#"Added Custom", "All", {"Name"}, {"Name.1"})
in
    #"Expanded All"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

1 REPLY 1
ImkeF
Community Champion
Community Champion

Hi @Nivas538 

you can do without the index like so:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlLSUXJJTQaShhb6hkb6RgaGliCOERLHQClWB6LSN7EIJGmub2AMlDQyAHGMkTlglclEmAlRmUK0mYlglZUQMw1M4ZImyBy4Sr/8MqjthnALDZE4Bkhm4rcdoZKIUIoFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Name = _t, EventName = _t, Edate = _t, Sdate = _t, Islatest = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Name", type text}, {"EventName", type text}, {"Edate", type date}, {"Sdate", type date}, {"Islatest", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Name"}, {{"All", each _}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each Text.Combine(Table.SelectRows([All], (x)=> x[Islatest]=0)[EventName], ", ")),
    #"Expanded All" = Table.ExpandTableColumn(#"Added Custom", "All", {"Name"}, {"Name.1"})
in
    #"Expanded All"

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.