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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
WILLIH
Helper I
Helper I

Id sequence

How do I get my id's to sort in order?

 

Power BI - Sort.PNG           Power BI - Sort 2.PNG

4 REPLIES 4
MFelix
Super User
Super User

Hi @WILLIH ,

 

Try the following code to add a custom column that you can then sort the other column by this one:

 

Power Query

try if  Value.Is (Number.From([ID]), type number) then Text.PadStart([ID], 10 , "0" ) else [ID] otherwise [ID]

Dax

Column = IF(IFERROR(VALUE('Table'[ID]);BLANK()) = BLANK();'Table'[ID];REPT("0";10 - LEN('Table'[ID])) & 'Table'[ID])

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix
Super User
Super User

Hi @WILLIH ,

 

You need to convert the values into number, on the query editor if you click 123/ABC button you can select number on format.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi MFelix,

I did try changing the format of the data to a number but it still does not let me sort it. You can't see it from the pictures but some of the id's also have alpha in them like "D0017" or "EB255". Would that make a difference because the data is still being recognized as text?

 

Thanks,

 

WILLIH

Hi @WILLIH  if you alphanumeric codes you cannot convert to number,

 

Believe the best option is to add a new column with some additional zeros to the left on alll the number so you can then sort the numbers. 

 

Not on computer now but will send out the code tomorrow. 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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