Forum Discussion

UmeshGoti's avatar
UmeshGoti
Helper I
1 year ago
Solved

Need to Create Semantic Layer by providing sql query

Hello Community,   As part of report migration to PowerBi. i am using Fabric Rest APIs (https://learn.microsoft.com/en-us/rest/api/fabric/semanticmodel/items/create-semantic-model?tabs=HTT...) to ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hello UmeshGoti ,

    Thank you for following up on my previous response.

     

    No, you generally don't need to manually define the column details and table names if your SQL query is well-formed and includes all the necessary tables and columns.

    Power BI will execute the query directly and infer the schema from the query's result. The columns and tables are automatically understood by Power BI based on the provided SQL.

     

    Power BI usually infers the schema from the SQL query automatically. However, manual intervention might be needed if it struggles with complex queries or derived columns.

    Prerequisites to Implement Semantic Model with Direct SQL Query in Power BI:

    • Ensure you have the connection string to your database in Base64 format.
    • You should have a valid API token or other authentication details to access the Power BI API.

    In a SQL query that pulls data from multiple tables, you typically use JOINs, subqueries, or other methods to combine the data. The most common approach is using JOIN statements.

    Before calling the API, try to build the connection string and use that connection string with SQL query to call the API.

    To send this request, use a POST method to the Power BI Fabric API using powershell or bash.

     

    I hope this help you understanding, if you need any further assistance, feel free to reach out.

     

    If this post helps, then please give us Kudos and consider Accept it as a solution to help the other members find it more quickly.

     

    Thank you.