In dictionary (double,double) count keys corresponding to certain values

Hello,

Could any UiPath Veteran help me solve this issue:
I have dictionary (key, value) of double, double. Im looking for a simplest way to count how many keys have value 0 connected with them.

Anyone ?
Kind regards
Krzysztof

Maybe we need some more inputs. Give a try at

Assign Acitvity
intCount | DataType: int32 =
yourDictVar.Count(Function (x) x.Value.equals(0))

yourDictVar.AsEnumerable().Count(Function (x) x.Value.Equals(0))

Update1 - Statement Correction
As yourDictVar.Count refers to the Count Property, so the LINQ Operator “Count” is not called. With the “AsEnumerable()” part, the usage of the LINQ Operator can be invoked.

Verification:
grafik

@Zdzichu_Map

Try this one

myDictionary.Count(Function(x) Math.Abs(x.Value) < 0.0001)

both solutions give same error: compiler errors encountered processing expression “dict.Count(Function(x) x.Value.equals(0))”.(2) :error BC32016: ‘Public overloads ReadOnly Property Count As Integer’ has no parameters and its return type cannot be indexed.

any ideas

It should be

yourDictVar.Values.Count(Function (x) x.Value = 0)

Stil same error:

compiler errors encountered processing expression “dict.Values.Count(Function(x) x.Value=0)”.(2) :error BC32016: ‘Public overloads ReadOnly Property Count As Integer’ has no parameters and its return type cannot be indexed.

im not sure i writen it correctly: i need to count how many KEYS are paired to value=0

please dont give up on me :frowning:

1 Like

@Zdzichu_Map

Use this expression

myDictionary.Values.Where(Function(value) value = 0).Count()

Dictionary:

Logic:

Output:

dict.Where(Function(x) cint(x.Value)=0).Count
see if this helps.

regards
SG.

1 Like

@Zdzichu_Map

Welcome to the community

you only need to add as enumerable to make it proper

Dict.Values.AsEnumerable().Count(Function(v) v = 0)

cheers

Thank you do much

Mydict.where… worked

Have a great dat !

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.