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
dpeters65
New Member

Duplicate values after Group By

Refresh fails with message "Column 'Restart Cause' in Table 'new_sort' contains a duplicate value [redacted for company privacy reasons] and this is not allowed for columns on the one side of a many-to-one relationship or for columns that are used as the primary key of a table."

 

But this shouldn't be possible, because the Restart Cause column is the result of a Group By:
= Table.Group(Source, {"Restart Cause"}, {{"Count", each Table.RowCount(_), Int64.Type}})

 

By definition, Group By's should result in no duplications. As a workaround to this odd Power BI behavior, I added another step to remove duplicates, even there shouldn't be any:

= Table.AddIndexColumn(#"Removed Duplicates", "Order", 1, 1, Int64.Type)

= Table.Distinct(#"Sorted Rows", {"Restart Cause"})

 

Even after that I'm still getting the error during apply or refresh!

Full steps in case it's relevant:

= Table.Group(Source, {"Restart Cause"}, {{"Count", each Table.RowCount(_), Int64.Type}})

= Table.Sort(#"Grouped Rows",{{"Count", Order.Descending}})

= Table.Distinct(#"Sorted Rows", {"Restart Cause"})

= Table.AddIndexColumn(#"Removed Duplicates", "Order", 1, 1, Int64.Type)

 

EDIT: copy/pasted the wrong step.

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Not sure if this applies here but when I see issues like this it is because M is case sensitive while DAX is not.  If you use UPPER or lower case of the column before you group, you will be sure to get rid of duplicates.

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Microsoft Employee
Microsoft Employee

Not sure if this applies here but when I see issues like this it is because M is case sensitive while DAX is not.  If you use UPPER or lower case of the column before you group, you will be sure to get rid of duplicates.

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Thank you mahoneypat! I didn't realize that DAX is case-insensitive.

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.