Given a group word w in k variables, a finite group G and g ∈ G, we consider the number N w,G (g) of k-tuples g 1 , . . . , g k of elements of G such that w(g 1 , . . . , g k ) = g. In this work we study the functions N w,G for the class of nilpotent groups of nilpotency class 2. We show that, for the groups in this class, N w,G (1) ≥ |G| k−1 , an inequality that can be improved to N w,G (1) ≥ |G| k /|G w | (G w is the set of values taken by w on G) if G has odd order. This last result is explained by the fact that the functions N w,G are characters of G in this case. For groups of even order, all that can be said is that N w,G is a generalized character, something that is false in general for groups of nilpotency class greater than 2. We characterize group theoretically when N x n ,G is a character if G is a 2-group of nilpotency class 2. Finally we also address the (much harder) problem of studying if N w,G (g) ≥ |G| k−1 for g ∈ G w , proving that this is the case for the free p-groups of nilpotency class 2 and exponent p.