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! Request now

Reply
o59393
Post Prodigy
Post Prodigy

How to group by to merge texts without duplicates

Hi all

 

I am trying on Power Query to go from this:

 

o59393_0-1628702725491.png

 

 

 

To this:

 

o59393_1-1628702725154.png

 

 

 

The only problem I have is that as seen above on column count, is duplicating me the values. How can I have distinct ones only?

 

Here is the M code:

 

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

 

Thanks!

2 ACCEPTED SOLUTIONS
CNENFRNL
Community Champion
Community Champion

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

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

CNENFRNL
Community Champion
Community Champion

#"Grouped Rows" = Table.Group(#"Changed Type", {"Id"}, {{"SR", each Text.Combine(List.Distinct([Sub Region]),", ")}, {"R", each Text.Combine(List.Distinct([Region]),", ")}, {"C", each Text.Combine(List.Distinct([Country]),", ")}})

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

View solution in original post

7 REPLIES 7
Syndicate_Admin
Administrator
Administrator

@CNENFRNL  question.

 

Is it possible to have more than one column?

 

In our solution we just have Sub region:

 

o59393_1-1628705091836.png

 

 

Can I have also region and country?

 

o59393_0-1628705078881.png

 

Could I try for example in the code:

 

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

 

?

 

Thanks!

o59393
Post Prodigy
Post Prodigy

@CNENFRNL  question.

 

Is it possible to have more than one column?

 

In our solution we just have Sub region:

 

o59393_1-1628705091836.png

 

 

Can I have also region and country?

 

o59393_0-1628705078881.png

 

Could I try for example in the code:

 

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

 

?

 

Thanks!

CNENFRNL
Community Champion
Community Champion

#"Grouped Rows" = Table.Group(#"Changed Type", {"Id"}, {{"SR", each Text.Combine(List.Distinct([Sub Region]),", ")}, {"R", each Text.Combine(List.Distinct([Region]),", ")}, {"C", each Text.Combine(List.Distinct([Country]),", ")}})

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

Hi @CNENFRNL 

 

I got the following error:

 

o59393_0-1628706731078.png

 

 

Could it be because of the renamed columns below?

 

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

 

Thanks!

It worked!! @CNENFRNL 

 

o59393_1-1628706813314.png

 

 

I changed it to:

 

#"Grouped Rows" = Table.Group(#"Changed Type", {"Id"}, {{"SR", each Text.Combine(List.Distinct([Sub Region]),", ")}, {"R", each Text.Combine(List.Distinct([Region]),", ")}, {"C", each Text.Combine(List.Distinct([Country]),", ")}})
in
#"Grouped Rows"

 

Thanks a million!!

o59393
Post Prodigy
Post Prodigy

Thanks @CNENFRNL !

CNENFRNL
Community Champion
Community Champion

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

Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is still way beyond their comprehension!

DAX is simple, but NOT EASY!

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.