cancel
Showing results for 
Search instead for 
Did you mean: 

How to count the columns in table

Manzoor
New Contributor

Hi Team,

I'm pulling data from the source system which have "n" columns, I wanted to count the number of columns that I'm getting from the Source System. So that to map them with the respective Target System.

Please help me out this, Thanks in advance.

1 ACCEPTED SOLUTION

Hi @Manzoor ,

You can use the following expression to replace the NULL values with blank in the entity object, assuming it is a flat object.

$entity.mapValues(val => val == null ? "" : val)

This will simply iterate over each value in the entity object, and check if the value is null, if it is, it will return an empty string otherwise it will return the original value.

View solution in original post

5 REPLIES 5

ivicakoteski
New Contributor II

Hi @Manzoor ,

You can try the $.keys().length expression in the mapper snap. This will give you length of array that will contain all headers from the source.

ivicakoteski_0-1692171225846.png

 


BR.
Ivica

j_angelevski
Contributor III

Hi @Manzoor ,

Do you mind sharing more details about this? What is the source system, what is the target system? Any data samples? What do you mean by "n" columns, not sure if you are referring to the keys in the input data or if the source system is a database, then you are referring to the table columns presumably?

 

@ivicakoteski  has already proposed a solution that will count the keys in the input document, let us know if that's what you are looking for.

Hi @j_angelevski 

Source System: Workday Prism

Target System: SAP Concur

Pulling Data from WDPrism via web service and pushing in to SAP Concur. While pulling data I'm getting few fields "Status", "Header', "Entity", "_debug".

In " entity " I have the reqiured data. In Which there are 137 fields that I need to Map and transform in to excel table.

Mapping and transformation in to excel is done. But columns having NULL value should be replaced by Blank value.

Can u help me out this. Bcz among 137 fields or say as excel columns I have almost 70+ NULL values in the in each record.

Thanks

Manzoor.Screenshot 2023-08-16 at 4.23.57 PM.png

Hi @Manzoor ,

You can use the following expression to replace the NULL values with blank in the entity object, assuming it is a flat object.

$entity.mapValues(val => val == null ? "" : val)

This will simply iterate over each value in the entity object, and check if the value is null, if it is, it will return an empty string otherwise it will return the original value.