How to tranpose data table from row to column before written to excel

Hi,

I have activity to tranpose data from row to column. The elements can be seen below :

So what I got right now from my robot is “Output Written to Data Table” where the customer name and ID are repetitively but the amount is correct.

I want the output as expected below… Where the value 5 million, 4 and half million is written to each column. (Jan 5 Million, Feb 4 and half million, etc)

Any help for this?

Hello @Rhys18

Can you please check the below post.

Hi,

I did saw that link before, but my concern is :

  1. What if the customer name is duplicate? if I transpose Customer name John Doe, wouldn’t it still be repetitively written or it will written only once as I expected?
  2. What should I fill in the add data column? Is it the variable of the value?

@Rhys18 you just need to new need to transpose 3rd column. First 2 columns then you can use remove duplicates rows.

Soo, I just found something that I just figured out now. The Column “Total 2” is ignored , and Transpose is working for headers, but there’s 1 problem that the month I want (as expected) is actually not a header… It’s a value, so it’s gonna be like this

image

@Rhys18 Can you keep a static template and copy the relevant data to the template.
Then you can keep the headers as required.

Unfortunately no, it can’t be a static template… If the robot is running on Jun, then first value of the column month will be Jun, If it’s running on March, then first value will be march, etc

Any1 can help on this?

Hi @Rhys18 ,

Is the Customer Name and Customer ID, going to be a single value always ? Meaning it’s going to be one value that is going to be repeated for Different Values and Month or Can we expect multiple customers being present in it as well ?

I got ur point… The customer name can be same also, but their ID might be different. So you can assume 1 customer can have 2 transactions like this :

image

So the unique Identifier is the Customer ID itself… Customer name can be the same

Hi @Rhys18 ,

Could you Check the Workflow below :
Transpose_ColumnsToRows (2).zip (10.2 KB)

The Output appears in the below Way :

We have assumed that the Column Names will be as provided for the Output, and hence the solution was derived accordingly.

Let us know if this is not the expected solution.

I got a question, based on the workflow you give… You are connecting the headers and the value right? Is it do able to tranpose without the header?

Because my robot is set static of Month-1 based on when the robot runs

(Example : if robot running on July, then starting month will be June, if the robot running on November, starting month will be October). I just need to transpose the Column value only

@Rhys18 ,

You could give a try with other samples that you have and let us know if it doesn’t work for any of them.

We are mapping the Month and Value as Dictionary, so that we can retrieve the values accordingly.

For aligning the values in the order required, we are using Month names as an array.

Do you do not want to have other columns which are empty ?

We have another way of Performing the Actual Transpose, but if it works out this way it should be fine.

The requirement is changing. So I just need to output the value based on month-1 and so on. So the value at the early will not be null, it will always have value. This can be done with getdate() in SQL query.

So by using month and value dictionary, it will written columns? Can I use this community package instead? Because when I tried using it, my value is transposed but it’s written in 1 single column.

Data Manipulations - RPA Component | UiPath Marketplace

Could you try with this with my case? Mine is transposed but still not as expected. Thanks !

@Rhys18 ,

I will use a Similar component, but could you let me know what is the Difference in output that you expect from the solution that was provided ?

The point of providing that solution was to reduce the dependency on other packages, or extensive row to Column shifting.

To be honest I haven’t tried so I don’t have any arguments for it… I’m just thinking if we can use a community package provided instead of making manual workflow, wasn’t it more better and more efficient?

@Rhys18 ,

We have more control on the parts where we need to modify the code/activity when we do it using simple activities. As you have mentioned, if a ready package is used, the transposed datatable may not be the exact output that you would require, we would require to alter it again later by adding few more steps to the flow.

To avoid that part, we can build the same logic from the source/start.

So in summary, it requires more logic and process?

@Rhys18 ,

If the Output is not as expected, yes, as your case does not look to be a direct transpose.

Then I guess that activity is not working. Because my workflow is :

Add Data Row → Tranpose → Outputted transpose saved data table and it goes straight to 1 single row…