Calling the OpenAI API from a Microsoft Fabric Notebook

Microsoft Fabric notebooks are a versatile tool for developing Apache Spark jobs and machine learning experiments. They provide a web-based interactive surface for writing code with rich visualizations and Markdown text support.

In this blog post, we’ll walk through how to call the OpenAI API from a Microsoft Fabric notebook.

Preparing the Notebook

Start by creating a new notebook in Microsoft Fabric. Notebooks in Fabric consist of cells, which are individual blocks of code or text that can be run independently or as a group. You can add a new cell by hovering over the space between two cells and selecting ‘Code’ or ‘Markdown’.

Microsoft Fabric notebooks support four Apache Spark languages: PySpark (Python), Spark (Scala), Spark SQL, and SparkR. For this guide, we’ll use PySpark (Python) as the primary language.

You can specify the language for each cell using magic commands. For example, you can write a PySpark query using the %%pyspark magic command in a Scala notebook. But since our primary language is PySpark, we won’t need a magic command for Python cells.

Microsoft Fabric notebooks are integrated with the Monaco editor, which provides IDE-style IntelliSense for code editing, including syntax highlighting, error marking, and automatic code completions.

Calling the OpenAI API

To call the OpenAI API, we’ll first need to install the OpenAI Python client in our notebook. Add a new cell to your notebook and run the following command:

!pip install openai

Next, in a new cell, write the Python code to call the OpenAI API:

import openai

openai.api_key = 'your-api-key'

response = openai.Completion.create(
  engine="text-davinci-002",
  prompt="Translate the following English text to French: '{}'",
  max_tokens=60
)

print(response.choices[0].text.strip())

Replace 'your-api-key' with your actual OpenAI API key. The prompt parameter is the text you want the model to generate from. The max_tokens parameter is the maximum length of the generated text.

You can run the code in a cell by hovering over the cell and selecting the ‘Run Cell’ button or bypressing Ctrl+Enter. You can also run all cells in sequence by selecting the ‘Run All’ button.

Wrapping Up

That’s it! You’ve now called the OpenAI API from a Microsoft Fabric notebook. You can use this method to leverage the powerful AI models of OpenAI in your data science and machine learning experiments.

Always remember that if a cell is running for a longer time than expected, or you wish to stop execution for any reason, you can select the ‘Cancel All’ button to cancel the running cells or cells waiting in the queue.

I hope this guide has been helpful. Happy coding!


Please note that OpenAI’s usage policies apply when using their API. Be sure to understand these policies before using the API in your projects. Also, keep in mind that OpenAI’s API is a paid service, so remember to manage your usage to control costs.

Finally, it’s essential to keep your API key secure. Do not share it publicly or commit it in your code repositories. If you suspect that your API key has been compromised, generate a new one through the OpenAI platform.

This blogpost was created with help from ChatGPT Pro

How Microsoft Fabric empowers data scientists to build AI solutions

Data science is the process of extracting insights from data using various methods and techniques, such as statistics, machine learning, and artificial intelligence. Data science can help organizations solve complex problems, optimize processes, and create new opportunities.

However, data science is not an easy task. It involves multiple steps and challenges, such as:

  • Finding and accessing relevant data sources
  • Exploring and understanding the data
  • Cleaning and transforming the data
  • Experimenting and building machine learning models
  • Deploying and operationalizing the models
  • Communicating and presenting the results

To perform these steps effectively, data scientists need a powerful and flexible platform that can support their end-to-end workflow and enable them to collaborate with other roles, such as data engineers, analysts, and business users.

This is where Microsoft Fabric comes in.

Microsoft Fabric is an end-to-end, unified analytics platform that brings together all the data and analytics tools that organizations need. Fabric integrates technologies like Azure Data Factory, Azure Synapse Analytics, and Power BI into a single unified product, empowering data and business professionals alike to unlock the potential of their data and lay the foundation for the era of AI¹.

In this blogpost, I will focus on how Microsoft Fabric offers a rich and comprehensive Data Science experience that can help data scientists complete their tasks faster and easier.

The Data Science experience in Microsoft Fabric

The Data Science experience in Microsoft Fabric consists of multiple native-built features that enable collaboration, data acquisition, sharing, and consumption in a seamless way. In this section, I will describe some of these features and how they can help data scientists in each step of their workflow.

Data discovery and pre-processing

The first step in any data science project is to find and access relevant data sources. Microsoft Fabric users can interact with data in OneLake using the Lakehouse item. Lakehouse easily attaches to a Notebook to browse and interact with data. Users can easily read data from a Lakehouse directly into a Pandas dataframe³.

For exploration, this makes seamless data reads from One Lake possible. There’s a powerful set of tools is available for data ingestion and data orchestration pipelines with data integration pipelines – a natively integrated part of Microsoft Fabric. Easy-to-build data pipelines can access and transform the data into a format that machine learning can consume³.

An important part of the machine learning process is to understand data through exploration and visualization. Depending on the data storage location, Microsoft Fabric offers a set of different tools to explore and prepare the data for analytics and machine learning³.

For example, users can use SQL or Apache Spark notebooks to query and analyze data using familiar languages like SQL, Python, R, or Scala. They can also use Data Wrangler to perform common data cleansing and transformation tasks using a graphical interface³.

Experimentation and modeling

The next step in the data science workflow is to experiment with different algorithms and techniques to build machine learning models that can address the problem at hand. Microsoft Fabric supports various ways to develop and train machine learning models using Python or R on a single foundation without data movement¹³.

For example, users can use Azure Machine Learning SDK within notebooks to access various features such as automated machine learning, hyperparameter tuning, model explainability, model management, etc³. They can also leverage generative AI and language model services from Azure OpenAI Service to create everyday AI experiences within Fabric¹³.

Microsoft Fabric also provides an Experimentation item that allows users to create experiments that track various metrics and outputs of their machine learning runs. Users can compare different runs within an experiment or across experiments using interactive charts and tables³.

Enrichment and operationalization

The final step in the data science workflow is to deploy and operationalize the machine learning models so that they can be consumed by other applications or users. Microsoft Fabric makes this step easy by providing various options to deploy models as web services or APIs³.

For example, one option for users is they can use the Azure Machine Learning SDK within notebooks to register their models in Azure Machine Learning workspace and deploy them as web services on Azure Container Instances or Azure Kubernetes Service³.

Insights and communication

The ultimate goal of any data science project is to communicate and present the results and insights to stakeholders or customers. Microsoft Fabric enables this by integrating with Power BI, the leading business intelligence tool from Microsoft¹³.

Users can create rich visualizations using Power BI Embedded within Fabric or Power BI Online outside of Fabric. They can also consume reports or dashboards created by analysts using Power BI Online outside of Fabric³. Moreover, they can access insights from Fabric within Microsoft 365 apps using natural language queries or pre-built templates¹³.

Conclusion

In this blogpost, I have shown how Microsoft Fabric offers a comprehensive Data Science experience that can help data scientists complete their end-to-end workflow faster and easier. Microsoft Fabric is an end-to-end analytics product that addresses every aspect of an organization’s analytics needs with a single product and a unified experience¹. It is also an AI-powered platform that leverages generative AI and language model services to enable customers to use and create everyday AI experiences¹. It is also an open and scalable platform that supports open standards and formats, and provides robust data security, governance, and compliance features¹.

If you are interested in trying out Microsoft Fabric for yourself, you can sign up for a free trial here: https://www.microsoft.com/microsoft-fabric/try-for-free.

You can also learn more about Microsoft Fabric by visiting the following resources:

I hope you enjoyed this blogpost and found it useful. Please feel free to share your feedback or questions in the comments section below.

Source: Conversation with Bing, 5/31/2023
(1) Data science in Microsoft Fabric – Microsoft Fabric. https://learn.microsoft.com/en-us/fabric/data-science/data-science-overview.
(2) Data science tutorial – get started – Microsoft Fabric. https://learn.microsoft.com/en-us/fabric/data-science/tutorial-data-science-introduction.
(3) End-to-end tutorials in Microsoft Fabric – Microsoft Fabric. https://learn.microsoft.com/en-us/fabric/get-started/end-to-end-tutorials.

Creating Paginated Reports RDL Files in SSDT with the Assistance of ChatGPT

Chris note: I was going to redo this to use Report Builder instead, but thought it’d be fun to leave it “old school” and use SQL Server Data Tools as the example.

Introduction

Reporting is a critical aspect of modern business operations. It enables decision-makers to understand the state of their business and make informed decisions. One common reporting solution utilized by businesses today is Microsoft’s SQL Server Reporting Services (SSRS). SSRS allows users to design and deploy comprehensive, interactive, and printed reports. An essential part of SSRS is the Report Definition Language (RDL), an XML standard used to define reports.

In this blog post, we’ll discuss how you can leverage the capabilities of ChatGPT, an AI language model developed by OpenAI, to facilitate the creation of RDL files. While the AI can’t directly write RDL files, it can guide you through the process, providing insight into best practices, troubleshooting, and automation potential.

Understanding RDL Files

Before we get into the process, let’s understand what RDL files are. Report Definition Language (RDL) is an XML markup language used for defining reports. It describes all necessary information needed for a report, including layout, query information, parameters, and more.

Creating an RDL file requires an understanding of XML structure, SQL queries for data retrieval, and the specific RDL schema. A basic understanding of SQL Server Reporting Services is also beneficial for deploying and managing these reports.

Step-by-Step Guide to Create an RDL File with ChatGPT Guidance

Step 1: Setting Up Your Environment

To create an RDL file, you need the appropriate development environment. Microsoft’s SQL Server Data Tools (SSDT) in Visual Studio is the standard tool for creating and editing RDL files. Download and install Visual Studio and the necessary SSDT if you haven’t done so already.

User: ChatGPT, where can I download the latest version of Visual Studio and SSDT?

ChatGPT: You can download Visual Studio from the official Microsoft website. As for the SQL Server Data Tools (SSDT), you can find it within the Visual Studio installer under 'Individual components'. Look for 'SQL Server Data Tools'.

Step 2: Creating a New Report

Open Visual Studio and create a new Report Server Project. Within this project, add a new Report item.

User: How do I create a new Report Server Project in Visual Studio?

ChatGPT: To create a new Report Server Project, follow these steps:
1. Open Visual Studio.
2. Click 'File' > 'New' > 'Project'.
3. In the new project dialog, search for 'Report Server Project'.
4. Choose the 'Report Server Project Wizard' option.
5. Specify your project name and location, then click 'Create'.

Step 3: Defining Data Sources and Datasets

Data sources define where your report data comes from, while datasets define what data to retrieve. They can be defined directly in the RDL file or can be shared among multiple reports.

User: How can I create a data source for my report in Visual Studio?

ChatGPT: Here are the steps to create a data source for your report:
1. In the Solution Explorer, right-click 'Shared Data Sources' and then click 'Add New Data Source'.
2. In the 'Shared Data Source Properties' dialog box, enter a name for the data source.
3. Select a data source type. For SQL Server, this would be 'Microsoft SQL Server'.
4. Enter your connection string or use the 'Edit' button to build it.
5. Click 'Test Connection' to ensure your settings are correct, then click 'OK' to create the data source.

Step 4: Designing Your Report

Designing your report includes creating tables, charts, and other visual elements, defining groupings, and applying formatting.

User: I want to add a table to my report. How can I do that?

ChatGPT: Here's how you can add a table to your report:
1. In the 'Report Data' pane, expand your dataset to see the available fields.
2. Right-click in the report designer and select 'Insert' > 'Table'.
3. Drag and drop fields from your dataset onto the table.
4. To adjust the size, borders, and other properties of the table and its cells, you can use the 'Properties' window.

Step 5: Defining Parameters

Parameters in an RDL report allow user interaction. Users can input values that filter or otherwise affect the report data.

User: I want to add a parameter to my report to filter the data by date. How do I set it up?

ChatGPT: To add a parameter to your report, follow these steps:
1. In the 'Report Data' pane, right-click 'Parameters' and select 'Add Parameter'.
2. In the 'Report Parameter Properties' dialog, give your parameter a name, such as "StartDate".
3. If necessary, you can set up available values or default values.
4. In your dataset query, you'll want to reference this parameter to filter your data. You would add something like "WHERE OrderDate >= @StartDate" to your SQL query.

Step 6: Testing and Deployment

Once your report design is complete, you should preview your report to ensure it looks and functions as expected. When satisfied, deploy the report to your report server.

User: How can I deploy my report to the report server?

ChatGPT: To deploy your report to the report server, follow these steps:
1. In Solution Explorer, right-click your project and select 'Properties'.
2. In the 'Property Pages' dialog box, specify the URL of your target report server in the 'TargetServerURL' field.
3. Click 'OK', then right-click your project again and select 'Deploy'.

Conclusion

Creating RDL reports can be a complex task due to the myriad of features and options available in SQL Server Reporting Services. However, with a tool like ChatGPT, you have a virtual assistant that can guide you through the process, answer your questions, and provide helpful suggestions.

Remember, while AI is an incredibly powerful tool, it’s just that—a tool. It won’t replace the need for human oversight, but it can dramatically streamline the process and make it more accessible. So why not leverage it to improve your reporting process? Happy reporting!

This blogpost was created with help from ChatGPT Pro.

Why ChatGPT Won’t Replace the Need for Data Analysts in the Future

Introduction

Artificial Intelligence (AI) has come a long way in recent years, thanks to groundbreaking research and technological advancements. One of the most notable AI innovations is ChatGPT, a large language model developed by OpenAI. With its advanced capabilities in natural language processing and understanding, ChatGPT has significantly influenced many industries, including data analysis.

However, despite the impressive performance of ChatGPT, it is crucial to understand that it will not replace the need for data analysts in the future. In this blog post, we will explore the reasons behind this assertion and discuss the unique value that data analysts bring to the table.

  1. Human Insight and Intuition

While ChatGPT is highly proficient in understanding and processing language, it lacks the human intuition and insight that data analysts possess. Data analysts are not only trained to interpret complex patterns and trends but also to provide context and reasoning behind the data. This level of understanding goes beyond simply recognizing patterns and requires a deep knowledge of the domain and the ability to make informed decisions based on that understanding. ChatGPT, as powerful as it is, cannot replicate the human touch that data analysts provide.

  1. The Art of Asking the Right Questions

Data analysts are experts in asking the right questions to drive actionable insights. They know how to tailor their approach to suit the specific needs of their clients, and they understand the importance of asking probing questions to uncover hidden trends and opportunities. ChatGPT, as an AI language model, is inherently limited in this regard, as it can only respond to the questions it is given, rather than proactively identifying areas of interest or potential pitfalls.

  1. Domain-Specific Expertise

Data analysts often specialize in specific industries or domains, bringing a wealth of knowledge and expertise to their work. They are familiar with the unique challenges and trends that characterize their chosen fields and are well-equipped to provide tailored solutions to these problems. While ChatGPT can process and analyze vast amounts of information, it lacks the domain-specific expertise that makes data analysts invaluable assets to their organizations.

  1. Data Quality and Data Preparation

A large part of a data analyst’s job involves cleaning, preparing, and transforming raw data into a format that can be easily analyzed. This process requires a deep understanding of the data, its sources, and its limitations, as well as the ability to identify and address any inconsistencies or inaccuracies. ChatGPT, on the other hand, is not designed to handle this crucial aspect of data analysis. It is, therefore, necessary to have data analysts in place to ensure that the data being used is accurate, relevant, and reliable.

  1. Ethical Considerations

Data analysts are trained to consider the ethical implications of their work, ensuring that data is collected, analyzed, and presented in a responsible and unbiased manner. This ethical awareness is particularly important given the increasing concerns surrounding data privacy and the potential for misuse of information. ChatGPT, while an impressive tool, is not equipped to navigate these complex ethical issues and cannot replace the thoughtful, human-driven approach that data analysts bring to their work.

Conclusion

Although ChatGPT has undoubtedly revolutionized the way we interact with and process data, it is essential to recognize that it cannot replace the need for data analysts in the future. Data analysts offer a unique blend of human insight, domain-specific expertise, and ethical awareness that simply cannot be replicated by an AI language model. By working together, ChatGPT and data analysts can complement each other’s strengths and drive more efficient and effective data-driven decision-making processes.

This blogpost was created with help from ChatGPT Pro.

Empowering Individuals with ADHD: The Benefits of ChatGPT

Introduction

Attention Deficit Hyperactivity Disorder (ADHD) is a neurodevelopmental disorder that affects millions of people worldwide. Characterized by difficulty paying attention, impulsivity, and hyperactivity, it can make everyday tasks and routines a challenge. In today’s fast-paced world, where there is an abundance of information and distractions, managing ADHD symptoms can be even more daunting.

Enter ChatGPT, an artificial intelligence language model developed by OpenAI. This cutting-edge technology has the potential to assist people with ADHD in a variety of ways. In this blog post, we will explore how ChatGPT can empower individuals with ADHD by enhancing organization, improving focus, and facilitating communication.

  1. Enhancing Organization

One of the most common challenges faced by people with ADHD is staying organized. ChatGPT can help in several ways:

  • Task management: ChatGPT can serve as a digital assistant, helping users create and manage to-do lists, set reminders, and prioritize tasks.
  • Structuring information: By providing clear and concise summaries of lengthy articles or documents, ChatGPT can make it easier for individuals with ADHD to process and retain information.
  • Habit formation: ChatGPT can be programmed to provide consistent reminders and positive reinforcement, assisting users in establishing and maintaining healthy habits and routines.
  1. Improving Focus

Maintaining focus can be difficult for individuals with ADHD, but ChatGPT can help users stay on track:

  • Filtering distractions: ChatGPT can be used to monitor incoming messages and notifications, only alerting users to high-priority items, allowing them to remain focused on the task at hand.
  • Mindfulness and relaxation techniques: ChatGPT can provide guided meditation and breathing exercises to help users reduce anxiety, improve focus, and achieve a calmer state of mind.
  • Customized focus strategies: ChatGPT can offer personalized suggestions and techniques for improving focus based on users’ preferences and needs.
  1. Facilitating Communication

People with ADHD may struggle with communication, whether it’s expressing themselves clearly or interpreting complex information. ChatGPT can help bridge these gaps:

  • Clear expression: ChatGPT can assist users in organizing their thoughts and presenting them in a clear, coherent manner, making communication more effective.
  • Active listening: By summarizing conversations, ChatGPT can help users maintain focus during discussions, ensuring they are better able to engage and respond.
  • Emotional support: ChatGPT can offer non-judgmental listening and encouragement, providing emotional support to users who may feel overwhelmed or isolated due to their ADHD.
  1. Capturing Creativity and Overcoming “Blank Page Syndrome”

People with ADHD often experience bursts of creativity, but may struggle to capture and develop these ideas due to challenges with focus and organization. Additionally, facing a blank page can be daunting for anyone, but particularly for individuals with ADHD who might struggle with initiating tasks. ChatGPT can support users in these areas:

  • Idea capturing: ChatGPT can serve as a readily available tool to record and store creative ideas as they arise. Users can easily input their thoughts, knowing that ChatGPT will save and organize them for future reference.
  • Idea development: ChatGPT can help users expand on their creative ideas by offering suggestions, asking thought-provoking questions, and providing relevant information or resources to fuel their brainstorming process.
  • Overcoming “blank page syndrome”: ChatGPT can help users break through the initial barrier of starting a project by providing writing prompts, outlines, or even drafting a brief introduction. By giving users a starting point, ChatGPT helps mitigate the anxiety and procrastination often associated with beginning a task.

Conclusion

ChatGPT offers valuable tools that can help individuals with ADHD better manage their symptoms and improve their daily lives. By enhancing organization, improving focus, facilitating communication, capturing creativity, and overcoming the challenges of starting with a blank page, this AI-powered technology can empower people with ADHD to thrive in today’s fast-paced world. As we continue to refine and develop ChatGPT, the potential applications and benefits for individuals with ADHD and other neurodevelopmental disorders will only continue to grow.

This blogpost was created with help from ChatGPT Pro.

Integrating OpenAI with Power BI Paginated Reports using Azure Functions

Introduction: Power BI Paginated Reports are ideal for creating highly formatted, pixel-perfect layouts optimized for printing or PDF generation. By integrating OpenAI with Power BI Paginated Reports using Azure Functions, you can enhance your reports with AI-generated insights and content. This blog post provides a step-by-step guide on how to integrate OpenAI with Power BI Paginated Reports using Azure Functions and an intermediary SQL Server database.

Prerequisites:

  • An OpenAI API key
  • An Azure account
  • Power BI Report Builder
  • Basic knowledge of Power BI Paginated Reports, Azure Functions, and C#

Step 1: Create a SQL Server database

  1. Set up a SQL Server database or use an existing one.
  2. Create a new table to store the AI-generated content:
CREATE TABLE OpenAI_Responses (
ID INT PRIMARY KEY IDENTITY(1,1),
Prompt NVARCHAR(MAX),
GeneratedText NVARCHAR(MAX),
DateGenerated DATETIME
);

Step 2: Create an Azure Function to call the OpenAI API and store the AI-generated content in the SQL Server database

  1. Set up an Azure Function App with an HTTP trigger and follow the instructions to create a new function.
  2. Add the necessary NuGet packages to call the OpenAI API (e.g., OpenAI) and connect to SQL Server (e.g., System.Data.SqlClient).
  3. Modify the Azure Function code to call the OpenAI API, and insert the AI-generated content into the SQL Server table.
using System.Data.SqlClient;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using OpenAI;

public static class OpenAIIntegrationFunction
{
[FunctionName("OpenAIIntegrationFunction")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
ILogger log)
{
log.LogInformation("C# HTTP trigger function processed a request.");

// Get the 'prompt' parameter from the query string
string prompt = req.Query["prompt"];

// Use OpenAI API Key
string openaiApiKey = Environment.GetEnvironmentVariable("OPENAI_API_KEY");

// Initialize the OpenAI API client
var apiClient = new OpenAIApiClient(apiKey: openaiApiKey);

// Set up the completion request
var completions = await apiClient.Completions.CreateAsync(
engine: "text-davinci-002",
new CompletionRequest
{
Prompt = prompt,
MaxTokens = 50,
N = 1,
Stop = null,
Temperature = 0.7,
}
);

string generated_text = completions.Choices[0].Text.Trim();

// Replace with your SQL Server connection string
string connectionString = "your_sql_server_connection_string";

using (SqlConnection connection = new SqlConnection(connectionString))
{
connection.Open();
using (SqlCommand command = new SqlCommand("INSERT INTO OpenAI_Responses (Prompt, GeneratedText, DateGenerated) VALUES (@Prompt, @GeneratedText, @DateGenerated)", connection))
{
command.Parameters.AddWithValue("@Prompt", prompt);
command.Parameters.AddWithValue("@GeneratedText", generated_text);
command.Parameters.AddWithValue("@DateGenerated", DateTime.UtcNow);

await command.ExecuteNonQueryAsync();
}
}

return new OkObjectResult("Data saved to the database.");
}
}

Copy and paste this code into your Azure Function App. Replace the your_sql_server_connection_string placeholder with your actual SQL Server connection string. This code assumes you have already set up an OpenAI API key as an environment variable within your Azure Function App.

  1. Save the function and test it to ensure it inserts the AI-generated content into the SQL Server table.

Step 3: Create a Power BI Paginated Report

  1. Open Power BI Report Builder.
  2. Create a new report or open an existing one.
  3. Add a new “Parameter” to the report:
    • In the “Report Data” pane, right-click “Parameters” and click “Add Parameter.”
    • Name the parameter “Prompt.”
    • Set the data type to “Text.”
    • Provide a default value or leave it blank.
  4. Add a “Textbox” to the report and set its value to the “Prompt” parameter: =Parameters!Prompt.Value

Step 4: Connect the Power BI Paginated Report to the SQL Server database

  1. In the “Report Data” pane, right-click “Data Sources” and click “Add Data Source.”
  2. Choose “Microsoft SQL Server” as the connection type and provide a name for the data source.
  3. In the “Connection string” field, enter your SQL Server connection string.
  4. Click “OK” to add the data source.
  5. In the “Report Data” pane, right-click “Datasets” and click “Add Dataset.”
  6. Choose the SQL Server data source you just created and click “Query Designer.”
  7. In the “Query Designer,” enter a SQL query to fetch the latest AI-generated content for the given prompt:
SELECT TOP 1 GeneratedText
FROM OpenAI_Responses
WHERE Prompt = @Prompt
ORDER BY DateGenerated DESC

8. Add the “Prompt” parameter to the query by clicking

“Add Parameter” in the “Query Designer.” 9. Close the “Query Designer” and click “OK” to add the dataset.

  1. Add a “Textbox” to the report and set its value to the AI-generated text: =First(Fields!GeneratedText.Value, "Dataset1")

Conclusion: You now have a Power BI Paginated Report that displays AI-generated content based on the prompt parameter. When the report is run, it will retrieve the latest AI-generated content for the given prompt from the SQL Server database and display it in the report. To update the AI-generated content in the SQL Server database, you can manually call the Azure Function with the specified prompt, or you can create a separate application to automate this process. The Azure Function will then call the OpenAI API, generate the text, and insert it into the SQL Server table.

This approach allows you to leverage the Power BI Paginated Report’s native support for SQL Server as a data source while still incorporating AI-generated content from the OpenAI API. It involves additional steps and requires an intermediary database, but it provides a viable solution for integrating OpenAI with Power BI Paginated Reports

This blogpost was created with help from ChatGPT Pro and Paginated Report Bear.