For complex SQL queries, you can use the Advanced option in the SQL Server dialog box to write your own custom SQL statement to retrieve specific data.
If you're using an on-premises SQL server that isn't directly accessible from the internet, you might need to set up an on-premises data gateway as an intermediary for Power BI to connect securely
For more quries related to Power Bi,
Data Writeback in Power BI , Forecasting and to overcome the limitations in Power BI check our website Inforiver.