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
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
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.