One of the crucial research issues in an IoT-based system is how to manage the huge amount of data transmitted by the potentially large number of sensors that form the system. Prior research has focused on centralized cloud-based 'Big Data' architectures for collecting, collating and analyzing the data. However, most of these scenarios accumulate thousands of petabytes in a short period of time, increasing the demand for more storage, and also slowing down speed of data analysis. Hence for real-time scenarios, e.g., agricultural crop tracking, traffic management, etc., such an approach would be impractical. Moreover, depending on the context in which the data is generated and is to be used, only a fraction of the data would be needed for analysis. Therefore, the challenges are to determine which data to keep and which to discard for both short term and long term usage, and define the contextual parameters along which this filtering is to be done. Hence one key problem addressed in this paper is how to define what data the user needs so that filtering algorithms can be defined to extract the data needed. To that end, in this paper, we present a goal driven, context-aware data filtering, transforming and integration approach for IoT-based systems. We propose a data warehousebased data model for specifying the data needed at particular levels of granularity and frequency, that drive data storage and representation (aligned with the Semantic Sensor Network ontology). Throughout our paper, we illustrate our ideas via a realistic running example in the smart city domain, with emphasis on traffic management, and also present a proof of concept prototype.