@Choukse, Deepu Thanks for reaching out. I tried using the same policy and i am able to fetch the actual value as shown below,
<set-variable name="test" value="@(context.Request.Url.Query.GetValueOrDefault("lastname",""))" />
could you please verify if the actual value is passed, it will have a default value if the parameter isn't found.
do let me know incase of further queries, I would be happy to assist you.