If you have an input on a dashboard that allows the user to choose an option you provide, then that will create a token, so you simply use that token in your SPL, e.g.
index=ABC sourcetype="xyz" data earliest= -14d@d latest= @s
| timechart span=15m partial=false count by data
| timewrap $wrap_token$ series=short
| table _time, s0, s1
| rename s0 as this_week, s1 as last_week,
however, there are some problems with your SPL in that when you are timecharting with a split by field, the field names are not S0 and s1, they are data_value_s0 etc, i.e. the value of your split 'data' field.
Also, if you are searching 14days and change the wrap period to 1d, then it will generate 14 values of s*.