You can do this, but you have to perform all the calculations in the data table. You can use expressions, similar to the advanced expressions here, to populate the x and k columns. Then the Pivot command can be used to perform the sum from the calculated values.
We posted an example to illustrate File > On-line examples.
The file produces this graph where you have a slider to vary the k value.