Forum Discussion

SlippySeal's avatar
SlippySeal
New Member
2 years ago
Solved

Best way to connect data from Fabric Notebook into Power Query

Hello!

 

I have a Microsoft Fabric notebook in which I am pulling API data using python and saving it as a dataframe. I am new to Microsoft Fabric, so I don't have a lot of knowledge of all the inner workings. I would like to pull this data into power query to merge with other queries and for use in PBI, but I am struggling to find an effective method to do this.

 

Thanks!

  • To pull data from a Microsoft Fabric notebook into Power Query for use in Power BI, you can follow these steps:

    1. Save Data from Notebook to a Storage Location:

      • Save your dataframe from the notebook to a location that Power BI can access, such as a CSV file in Azure Blob Storage, OneDrive, or SharePoint.
    2. Connect Power Query to the Storage Location:

      • Use Power Query to connect to the storage location where you saved the file.

    Here’s a detailed guide to achieve this:

    Step 1: Save Dataframe to a Storage Location

    1. Save as CSV in Azure Blob Storage:

      • If you have Azure Blob Storage, you can save your dataframe directly to a blob container.

    from azure.storage.blob import BlobServiceClient
    import pandas as pd

    # Your dataframe
    df = pd.DataFrame(data)

    # Save dataframe as CSV
    csv_data = df.to_csv(index=False)

    # Azure Blob Storage details
    connection_string = "your_connection_string"
    container_name = "your_container_name"
    blob_name = "your_file_name.csv"

    # Create the BlobServiceClient object
    blob_service_client = BlobServiceClient.from_connection_string(connection_string)
    blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)

    # Upload the CSV data
    blob_client.upload_blob(csv_data, overwrite=True)

     

    Step 2: Connect Power Query to the Storage Location

    1. Connect to Azure Blob Storage:

      • In Power BI Desktop, go to Home > Get Data > Azure > Azure Blob Storage.
      • Enter your storage account name and access key.
      • Navigate to your container and select the CSV file.
    2. Connect to OneDrive or SharePoint:

      • In Power BI Desktop, go to Home > Get Data > SharePoint Folder.
      • Enter the SharePoint site URL and connect.
      • Navigate to the folder containing your CSV file and select it.
    3. Load and Transform Data in Power Query:

      • Once you have connected to the storage location and selected your file, the data will be loaded into Power Query Editor.
      • Perform any necessary transformations and merge with other queries.
      • Load the transformed data into Power BI for further analysis.

1 Reply

  • To pull data from a Microsoft Fabric notebook into Power Query for use in Power BI, you can follow these steps:

    1. Save Data from Notebook to a Storage Location:

      • Save your dataframe from the notebook to a location that Power BI can access, such as a CSV file in Azure Blob Storage, OneDrive, or SharePoint.
    2. Connect Power Query to the Storage Location:

      • Use Power Query to connect to the storage location where you saved the file.

    Here’s a detailed guide to achieve this:

    Step 1: Save Dataframe to a Storage Location

    1. Save as CSV in Azure Blob Storage:

      • If you have Azure Blob Storage, you can save your dataframe directly to a blob container.

    from azure.storage.blob import BlobServiceClient
    import pandas as pd

    # Your dataframe
    df = pd.DataFrame(data)

    # Save dataframe as CSV
    csv_data = df.to_csv(index=False)

    # Azure Blob Storage details
    connection_string = "your_connection_string"
    container_name = "your_container_name"
    blob_name = "your_file_name.csv"

    # Create the BlobServiceClient object
    blob_service_client = BlobServiceClient.from_connection_string(connection_string)
    blob_client = blob_service_client.get_blob_client(container=container_name, blob=blob_name)

    # Upload the CSV data
    blob_client.upload_blob(csv_data, overwrite=True)

     

    Step 2: Connect Power Query to the Storage Location

    1. Connect to Azure Blob Storage:

      • In Power BI Desktop, go to Home > Get Data > Azure > Azure Blob Storage.
      • Enter your storage account name and access key.
      • Navigate to your container and select the CSV file.
    2. Connect to OneDrive or SharePoint:

      • In Power BI Desktop, go to Home > Get Data > SharePoint Folder.
      • Enter the SharePoint site URL and connect.
      • Navigate to the folder containing your CSV file and select it.
    3. Load and Transform Data in Power Query:

      • Once you have connected to the storage location and selected your file, the data will be loaded into Power Query Editor.
      • Perform any necessary transformations and merge with other queries.
      • Load the transformed data into Power BI for further analysis.