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

To get a specific a row at top irrespective of the sorting

krishnanvs_0-1677506621242.png 1. This is my Data having country column and population column

krishnanvs_1-1677506680499.png

krishnanvs_2-1677506729224.png 2. however i sort whether ascending or descending by population, i need total row at top.

 

 

1 REPLY 1
v-rzhou-msft
Community Support
Community Support

Hi @Anonymous ,

 

Here I suggest you to add an index column in Power Query Editor to sort your visual.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8sxLyUxU0lEyNDJXitWJVnLOyMyD8A3AfI/8vHRvIAYJQURCg4Fscwg7JL8kMQfINTUA6o4FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Country = _t, #"Population/B" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Country", type text}, {"Population/B", Int64.Type}}),
    #"Sorted Rows" = Table.Sort(#"Changed Type",{{"Population/B", Order.Ascending}}),
    #"Added Index" = Table.AddIndexColumn(#"Sorted Rows", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "New Index", each if [Country] = "Total" then 1 else [Index] +1),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Index"})
in
    #"Removed Columns"

New Table:

RicoZhou_0-1677652007392.png

Sort [Country] by [New Index] column. Then sort visual by [Country] by ascending.

RicoZhou_1-1677652066639.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.