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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
jpulley3
New Member

Sort by row number unique values erroneous error

I have a sql view that contains a column for ID, date, value, and row number. I want to show the data sorted by ID and date, but when the value column is added it changes the sort to ID and value. I tried to use sort by another column to have the ID sorted by the row number but I get an error that says the row number value needs to be unique for each id value. Row number column in the view is [ROW_NUMBER() OVER(PARTITION BY id ORDER by date) as row#] so I know its unique. What gives?sort by error.png

1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

I think you're misunderstanding the message.  "error that says the row number value needs to be unique for each id value" - that's not what it says. 

It says "There can't be more than one value in row# for the same value in id" so it's looking at , for example id = a and saying, "right, what value do i use to sort this" and it gets 1,2,3,4,5,6 etc. so it doesn't know what to do. What it wants is 1 value for "a", 1 value for "b" and so on.

Now, all that explanation doesn't really help you sort your data but at least you'll know what's happening.

View solution in original post

1 REPLY 1
HotChilli
Super User
Super User

I think you're misunderstanding the message.  "error that says the row number value needs to be unique for each id value" - that's not what it says. 

It says "There can't be more than one value in row# for the same value in id" so it's looking at , for example id = a and saying, "right, what value do i use to sort this" and it gets 1,2,3,4,5,6 etc. so it doesn't know what to do. What it wants is 1 value for "a", 1 value for "b" and so on.

Now, all that explanation doesn't really help you sort your data but at least you'll know what's happening.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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