Hello,
My guess is you're not using BW but Universes as source right ?
If so, not that, by design by SAP, setFilter return everything if no data. On BW, this unexpected is not here, and the dataset would be empty.
I would suggest to create a separated datasource with aggregated data on with your years and use the getData function to check if you have something meaningfull, and implement your behavior.
We have a incredibly hard time with the setFilter on universes ...
If you're using only charts, you can also use setDataSelection instead , whereas no data will be displayed (but you will not be able to know it ...).
Hope it helps.