Skip to main content
16-Pearl
Nov 7, 2023 10:46 AM UTC
Solved

When distinct API used for a column, other columns data of infotable also should present in output

I have 5 columns in infotable. When Distinct API used for first two columns together, the output infotable should have 5 columns with the distinct values of first 2 columns. How to do this

VelkumarAnswer
19-Tanzanite
Nov 8, 2023 4:50 AM UTC

Hi @AP_10343008 

 

It won't take much time. Because you already pulled 4000 rows of data from Windchill and filtered distinct values out of it. 

 

The script will reuse the initially pulled data from the Windchill System it won't make any new calls to Windchill system

 

/VR

6 replies

19-Tanzanite
Nov 7, 2023 12:26 PM UTC

Hi @AP_10343008 

 

You can create query based on your distinct value and merge infotable into single table to get all columns value with distinct value of column1 & column2

// result: INFOTABLE 
let data = me.dummyData();


let params = {
 t: data /* INFOTABLE */ ,
 columns: "Column1,Column2" /* STRING */
};

// result: INFOTABLE
let distinctValue = Resources["InfoTableFunctions"].Distinct(params);

// CreateInfoTableFromDataShape(infoTableName:STRING("InfoTable"), dataShapeName:STRING):INFOTABLE()
let result = Resources["InfoTableFunctions"].CreateInfoTableFromDataShape({
 infoTableName: "InfoTable",
 dataShapeName: "testShape"
});

for (var i = 0; i < distinctValue.length; i++) {
 // Provide your filter using the format as described in the help topic "Query Parameter for Query Services"
 let query = {
 "filters": {
 "type": "And",
 "filters": [{
 "fieldName": "Column1",
 "type": "EQ",
 "value": distinctValue.rows[i].Column1
 },
 {
 "fieldName": "Column2",
 "type": "EQ",
 "value": distinctValue.rows[i].Column2
 }
 ]
 }
 };

 let params = {
 t: data /* INFOTABLE */ ,
 query: query /* QUERY */
 };

 // result: INFOTABLE
 let tempData = Resources["InfoTableFunctions"].Query(params);

 let params2 = {
 t1: result /* INFOTABLE */ ,
 t2: tempData /* INFOTABLE */
 };

 // result: INFOTABLE
 result = Resources["InfoTableFunctions"].Union(params2);

}

 

/VR

Translate
16-Pearl
Nov 7, 2023 4:35 PM UTC

As I have fetched 4000 data from windchill, it will take more time to use for loop. So any ither time saving way is there to get all column data by making 2 columns distinct.

Translate
Velkumar19-TanzaniteAnswer
19-Tanzanite
Nov 8, 2023 4:50 AM UTC

Hi @AP_10343008 

 

It won't take much time. Because you already pulled 4000 rows of data from Windchill and filtered distinct values out of it. 

 

The script will reuse the initially pulled data from the Windchill System it won't make any new calls to Windchill system

 

/VR

Translate