Hi Team,
Take 5-string any random value(ex:-‘A’, ‘B’, ‘A’, ‘C’, ‘A’) write a logic, :-let say
out of 5-value, 3-value are repeated , I want to find out % of that repetitive value.
Note:-Here repeat value is ‘A’, in this condition . what is the % of ‘A’.
Hi @sfdc_sfdc
So if we take random string values and store in a list of strings
Ex: List1 = {“A”,“B”,“C”,“A”,“A”}
To find the percentage of the repetitive value you can use the below linQ
dict=List1.GroupBy(Function(x) x).Where(Function(grp) grp.Count() > 1).ToDictionary(Function(g) g.Key, Function(g) (100 * g.Count() / List1.Count).ToString() + “%”)
where dict is a dictionary<String,String>
Hope this helps!
Hi @sfdc_sfdc
Can you try the below
listOfValues = New List(Of String) From{"A", "B", "A", "C", "A"}
percentage = ((listOfValues.Where(Function(x) x = listOfValues.GroupBy(Function(y) y).OrderByDescending(Function(g) g.Count()).First().Key).Count() / listOfValues.Count()) * 100).ToString
Regards,
1 Like
Hi Sanjay,
Thanks for your response,
If u can share screenshot of activity or XML based script, it will be more help full.
Thanks for your response,
Pls let me know what is the Variable type ?
Regards,
1 Like
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.