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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Anonymous
Not applicable

Sort Rows by Positive and Negative

Hello,

Please see below requirements,

How can i sorting out rows ,so that matching positive and negative numbers are found and sorted next to each other?

BEFORE

Date

Type

Amount

Result

9/1/2015

R

45

Y

13/01/2016

B

50

Y

13/01/2016

X

-62

N

9/1/2015

R

-45

N

9/1/2015

BA

80

Y

9/1/2015

B

-50

N

8/2/2005

X

62

Y

9/1/2015

BA

-80

N

    

AFTER

Date

Type

Amount

Result

9/1/2015

R

45

Y

9/1/2015

R

-45

N

13/01/2016

B

50

Y

9/1/2015

B

-50

N

13/01/2016

X

-62

N

8/2/2005

X

62

Y

9/1/2015

BA

80

Y

9/1/2015

BA

-80

N

 

1 ACCEPTED SOLUTION

 

Hi @Anonymous

 

You may add a custom column in query editor and then sort by the custom column.

if [Amount] < 0 then [Amount]*-1 else [Amount]

 1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
AkhilAshok
Solution Sage
Solution Sage

You could try creating a new measure which gives Abs(SUM(Table[Amount])), and sort Ascending based on this measure.

Anonymous
Not applicable

Hi Akhil,

thank you so much for your suggestion.Is it possbile i can use the same formula in Power Query (Language M).? 

Thanks

Anonymous
Not applicable

Thank you so much Akhil.

 

Hi @Anonymous

 

You may add a custom column in query editor and then sort by the custom column.

if [Amount] < 0 then [Amount]*-1 else [Amount]

 1.png

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Thank you so much Cherie.

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.