If you've selected the Direct Query Data Source option from the Data Flow, then you can add a custom table from the Tables window (in Data Modeling).
Start by opening the custom query dialog. This can be done by:
- Clicking the Add Custom Query Table button from the ribbon (red highlight below), or;
- Right clicking on the canvas and selecting 'Add table from a custom query' (blue highlight)
- From the Add Custom Query Table dialog, name the new table
- Write your query in SQL, and then test the query
- Click the Add button to add the table to the relationships flow
- Add a relationship to the new table