After creating the variable in the input box, go to the constraints tab and put the two group names in the Listed Values field and enable the option 'Predefined Values in Drop-down' Then in the chart add a calculated dimension that would be =$(Variable).
I've just tested this with dimensions and not dimension groups, but I hope it works.
I tried the same way you did. In dimension we are able to see the values passed through the input box.
It is working in the below way. Consider you have the table T1 and has the columns and values as below
A B C
1 P1 open
2 P2 open
3 P3 open
Create a input box and if the Input box has the predefined value as the Column name like B then the same is called in the Chart Dimension it is showing the irrelevant value.However if the Actual value of the Coulmn B is there in the Inputbox drop down then the chart is showing the correct Value.
It is working only when we pass the value of the Feild. it is not working for the dimension groups.........
i dont know is there any way to include the feild name in the dimension through Input box and chart should consider that as the feild name and invoke the feild values rather considering the value of feild.