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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. 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
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.