Hi All,
I have an array/list as below. I would like to get a array as list of elements and its counts like total: {{"In Dev" ,2} , {"In Prod",4},{"In Uat",1}}
Could anyone help me with code snippet? appreciate your help. Thanks in Advance ,
Rajesh
Discussion posts and replies are publicly visible
Hi Rajesh,
Try as below,
Create a rule Example:- EX_test with two rule inputs,array:(text)-multiple, value:text/*logic to count a word in the array*/{ ri!value, count( wherecontains( ri!value, ri!array ) )} /*sample output---{"In Dev",2}*//*Create a main rule using below snippet*/with( local!list: { "In Dev", "In Prod", "In Uat", "In Dev", "In Prod", "In Uat" }, local!totalelements: union( local!list, local!list ), local!array: apply( rule!EX_test( array:local!list, value:_ ),local!totalelements),local!array)
Hope it helps.