Professional Documents
Culture Documents
Practical12345 Guide To ChatGPT in Power BI 1698956492
Practical12345 Guide To ChatGPT in Power BI 1698956492
ChatGPT in Power BI
Mathias Halkjær
Principal Architect
Content
1. What is ChatGPT
Yes No
Yes No No
• Go to platform.openai.com
• Create an account, confirm your e-mail, add account details and confirm your phone number
• Copy the key. For security reasons, you won't be able to view it again through your OpenAI account.
• If you lose this secret key, you'll need to generate a new one.
Useful links:
🔗 ChatGPT API documentation
🔗 Pricing (openai.com)
Power Query Function
Ready-to-use
Power Query Function
Ready-to-use
let
Output = (prompt as text) as text =>
let
url = "https://api.openai.com/v1/chat/completions",
apiKey = "INSERT API KEY HERE",
headers = [
#"Content-Type" = "application/json",
#"Authorization" = "Bearer " & apiKey
],
body = Json.FromValue([model = "gpt-3.5-turbo", messages = {[role="user", content = prompt]}]),
response = Web.Contents(url, [Headers=headers, Content=body]),
content = Json.Document(response)[choices]{0}[message][content]
in
content
in
Output
Source: https://www.fluxbi.com/blog/how-to-use-chatgpt-in-power-bi
How-to guide
How to import and configure the function
• Create a new blank query, paste the function into the “Advanced Editor”
• Replace the text "INSERT API KEY HERE" with your own API key
(e.g. like this "sk-5nEAGEHxZ2QqhUUpIQT3BlbkFJyMx0Tl9bbjKnYDLDlo01")
How to import and configure the function
• Optionally: give it a test drive by writing a prompt to ChatGPT and invoking the function
Using ChatGPT on your data
Using ChatGPT on your Power BI data
Finally, to enrich some actual data with a new column using ChatGPT, repeat the following steps:
• Pick the ChatGPT function. Just start out with some static text.
• Modify the text to your desired prompt, including data from your dataset as referenced column.
(See example)
Voila!
Enjoy!
Mathias Halkjær
Principal Architect