Author Topic: how to sort the pivot columns  (Read 2033 times)

徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
how to sort the pivot columns
« on: July 24, 2020, 05:09:02 pm »
i have a data array like the under code:
day,   year,  brand, sale
'day1',2019,'A1',1000
'day1',2020,'A1' ,2000
'day2',2019,'A2',3000
'day2',2020,'A2',4000
'day1',2019','日合计',4000
'day2','2020','日合计',6000
when my groupcols is brand,year,i want the '日合计' groupcol is at the last.
what should i do?


徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: how to sort the pivot columns
« Reply #1 on: July 24, 2020, 05:42:44 pm »
how to sort the pivot columns,or how to set a pivot column to the last position?

paramvir

  • Administrator
  • Hero Member
  • *****
  • Posts: 6313
    • View Profile
Re: how to sort the pivot columns
« Reply #2 on: July 27, 2020, 08:29:39 am »
You need to define colModel and use pivotSortFn on the column bound to '日合计' data to sort the group cols.

https://paramquery.com/pro/api#option-column-pivotSortFn
« Last Edit: July 27, 2020, 08:36:16 am by paramvir »

徐雪峰

  • Pro Enterprise
  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: how to sort the pivot columns
« Reply #3 on: July 27, 2020, 04:32:08 pm »
I still don't understand the api's paramater. i think i don't know how to use it.
I change the collumn name to let the '日合計' displayed at the last column.