Skip to main content
added 122 characters in body
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59

One approach, calling ReverseSort only on the relevant data:

Query[ReverseSort[Query[;;-2(ReverseSort@Most@Query[All,-1]@data]"22"]@data//Keys//Append["Total"]]@dataAppend["Total"]//Query)@data//Dataset

enter image description here

Original Answer

Query[ReverseSort[Query[;;-2,-1]@data]//Keys//Append["Total"]]@data

One approach, calling ReverseSort only on the relevant data:

Query[ReverseSort[Query[;;-2,-1]@data]//Keys//Append["Total"]]@data//Dataset

enter image description here

One approach, calling ReverseSort only on the relevant data:

(ReverseSort@Most@Query[All,"22"]@data//Keys//Append["Total"]//Query)@data//Dataset

enter image description here

Original Answer

Query[ReverseSort[Query[;;-2,-1]@data]//Keys//Append["Total"]]@data
Source Link
user1066
  • 22.7k
  • 3
  • 36
  • 59

One approach, calling ReverseSort only on the relevant data:

Query[ReverseSort[Query[;;-2,-1]@data]//Keys//Append["Total"]]@data//Dataset

enter image description here