If condition: Check if sheet is formatted as a table

Hi,
Two pivot tables are to be created from one Excel sheet. Within the Use Excel File Activity, the data must be formatted as a table in order to create a pivot table. The same data basis is needed for both pivot tables.

Case 1: Both pivot tables do not exist yet: The bot formats the data base into a table and creates the pivot tables. Everything is fine.

Case 2: One of the two pivot tables is missing, so the bot only needs to create one pivot table from the data base that has already been formatted as a table.

In order to use the data base that is already formatted as a table, I wanted to add an if-condition that checks if the data base is already formatted as a table. UiPath returns the error that a table cannot overlap another table if it is already formatted as a table. For this reason the if-condition should be inserted before it.

Do you have any ideas?

Thanks in advance!

Hello @stefi

Is this error happening in the pivot activity?

If yes, try to create the pivot in a new sheet to resolve this issue.

Hi @Rahul_Unnikrishnan

No the error is not happening in the pivot activity but in the Format as Table activity.

Do you have any other ideas?

Can you refer to the below video? If you are creating the pivots in 2 different sheets or without overlapping to another, i think it will work fine with Create Pivot activity.

The pivot tables do not overlap, they are in two separate sheets.

The point is, if the bot crashes in the meantime and only one pivot table is created, then the bot should check if both pivot tables are present on the second run.

If one pivot table is missing, it should create it afterwards with the existing data.

To create a pivot table you have to use the Activity Format as a Table. But since the bot has already created a pivot table, the data base is already formatted as a table, which leads to the above mentioned error.

ok…what you can do is create the sheet each time during the execution. If the sheet presents then skip, else create the sheet and create the pivot.

I solved the issue with try catch: Within the try section I set the Format as Table activity. In the catch section I set the Get table Range activity where the output variable is the Pivottablename variable which is also used in Format as Table activity.

However, thanks for your help!

Can you share me the workflow

Hi @Aleem_Khan ,

Here the xaml and the associated excel file as example:

Main.xaml (22.6 KB)
ExcelFile.xlsx (8.9 KB)

Hope that helps.

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.