Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create Jupyter Notebook for Power BI Desktop - Get Text from Gist - Basic Connection Example
{
"cells": [
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"server = '<<PowerBIServer>>'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"database = '<<PowerBIDatabase>>'"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import sys \nimport ssas_api as powerbi \nimport pandas as pd"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"conn = \"Provider=MSOLAP;Data Source=<<PowerBIServer>>;Initial Catalog='';\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"dax_string = 'EVALUATE ROW(\"Loading .NET assemblies\",1)' \ndf = powerbi.get_DAX(connection_string=conn, dax_string=dax_string)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import System \nfrom System.Data import DataTable \nimport Microsoft.AnalysisServices.Tabular as TOM \nimport Microsoft.AnalysisServices.AdomdClient as ADOMD"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Sample TOM Connection \nTOMServer = TOM.Server() \nTOMServer.Connect(conn)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"#Sample DAX query \npowerbi.get_DAX(conn, \"EVALUATE 'Table'\")"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.6"
}
},
"nbformat": 4,
"nbformat_minor": 4
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.