Skip to content

Instantly share code, notes, and snippets.

@deldersveld
Last active August 16, 2020 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save deldersveld/70e05dbc97086181641592f03d314800 to your computer and use it in GitHub Desktop.
Save deldersveld/70e05dbc97086181641592f03d314800 to your computer and use it in GitHub Desktop.
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