How to sort the column in pivot table

Hello, I’m new to UiPath, I’m practising “create pivot table”, and wondering if I can sort the “value” column as we usually do in Excel. I tried “sort range” several times, but failed. not sure whether “sort range” is the correct way to do the simply sorting for pivot table.

1 Like

As there is no official activity, You can use VBA code for sorting pivot table.

1 Like

Hey @CHEN_YIJIAN

Could you please show the screenshot and highlight on what you are trying to sort here ?

Thanks
#nK

Hi

Welcome to uipath forum

I think there is no direct activity to sort pivot table in excel in studioX

You can try with vb script here with invoke code activity

This example sorts the Company field in descending order, based on the sum of sales.

ActiveSheet.PivotTables(1).PivotField("Company") _ 
 .AutoSort xlDescending, "Sum of Sales"

Cheers @CHEN_YIJIAN


screenshot post. hope it explains well. thanks.

1 Like

thanks for your reply, may I know how to use “invoke code activity”?

1 Like

Hey @CHEN_YIJIAN

This should help - Sort Table

If that’s not let us know, what’s the challenge/issue you are facing.

Thanks
#nK

thanks for your feedback, example in this link can not be opened, coz I’m StudioX user not Studio user. Also according to other people’s advice under this question, I would resort to VBA to see if it works.

1 Like

Hey @CHEN_YIJIAN

It is Sort Range in StudioX.

Have you tried that and any issue ?

Thanks
#nK

Hi

Check this doc for an example on how to to use invoke code activity

Cheers @CHEN_YIJIAN

thanks for reply. it seems no such activity in StudioX.

1 Like

image
Main.xlsx (6.9 KB)
attached the main.xlsx for reference.

Fine

Go to activity panel and right click that filter symbol

Enable SHOW DEVELOPER and then try searching for that activity

Cheers @CHEN_YIJIAN

1 Like

@CHEN_YIJIAN Can you share the sample excel file with PIVOT table that you created

@CHEN_YIJIAN You can read the PIVOT table to a data table from where you can sort using Sort data table activity (Ascending or Descending)

Please find the attached sample workflow based on Ascending sorting

Example.zip (25.5 KB)

1 Like

after enabled “Show Developer”, it has only “Invoke Method” rather than “Invoke Code”, FYI.

thanks for this new thought. unfortunately the attachement can’t be opened due to the incompatibility…anyway i will try to figure it out by using this method. thank you!

I tried to switch to Studio, but failed. export log attached, could you pls help verify whether the pkgs are available? thanks.
output.txt (3.2 KB)

@CHEN_YIJIAN Can you please go to your package manager and check the latest version of excel, system and UIautomation activities. So that I can degrade the packages to that version and can send you updated code

@CHEN_YIJIAN Try with the attached one

Example.zip (51.2 KB)