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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
o59393
Post Prodigy
Post Prodigy

How to combine only unique values for different columns

Hi 

 

I have gone from 

 

o59393_0-1628705706080.png

 

 

to

 

o59393_1-1628705717335.png

 

 

Would it be possible in the second image to include the Region and Country in separated columns?

 

I try the code:

 

#"Grouped Rows" = Table.Group(#"Changed Type", {"Id"}, {{"Count", each Text.Combine(List.Distinct([Sub Region],[Region],[Country]),", "), type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Grouped Rows",{{"Count", "Sub Region","Region","Country"}})
in
#"Renamed Columns"

 

But I get an error.

 

Is it possible to have this in M code?

 

Thanks.

 

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @o59393 

 

I think you probably want to do it

#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {
{"Sub Region", each Text.Combine(List.Distinct([Sub Region]),", "), type text}
,{"Region", each Text.Combine(List.Distinct([Region]),", "), type text}
,{"Country", each Text.Combine(List.Distinct([Country]),", "), type text}
})
in
    #"Grouped Rows"

View solution in original post

2 REPLIES 2
o59393
Post Prodigy
Post Prodigy

Thanks 🙂 @Vera_33 

Vera_33
Resident Rockstar
Resident Rockstar

Hi @o59393 

 

I think you probably want to do it

#"Grouped Rows" = Table.Group(#"Changed Type", {"ID"}, {
{"Sub Region", each Text.Combine(List.Distinct([Sub Region]),", "), type text}
,{"Region", each Text.Combine(List.Distinct([Region]),", "), type text}
,{"Country", each Text.Combine(List.Distinct([Country]),", "), type text}
})
in
    #"Grouped Rows"

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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