Does Power BI parameters are exposed to Python globals(Power BI 参数是否暴露给 Python 全局变量)
问题描述
我正在使用 Python 脚本处理 Power BI 请求.我可以通过 dataset 全局变量获取数据集,但现在我希望能够直接在我的 Python 脚本中获取传递的参数.
I'm working on Power BI requests with Python scripting.
I'm able to get the dataset through dataset global variable, but now I'd like to be able to get the passed parameters directly in my Python script.
我尝试打印"(我们不能真正直接在 PowerBI 中打印,所以我使用 raise Exception(WhatIWantToDebug) 以便直接在 PowerBI 中查看我的错误)globals(),它显示了在 Python 脚本的上下文中声明可访问的所有全局变量,但我无法找到任何有关参数的内容.不过我可以看到数据集.
I tried to "print" (we cannot really print directly in PowerBI so I use raise Exception(WhatIWantToDebug) in order to see my error directly in PowerBI) the globals(), which show all the globals variables declared accessible in the context of the Python script, but I'm not able to find anything concerning parameters. I'm able to see dataset though.
提前感谢您的解决方案想法
Thanks in advance for your solutions ideas
推荐答案
我终于找到了解决问题的方法.所以没弄清楚如何在Python中直接获取参数.
I've finally find a solution to my problem. So I didn't figure out how to get parameters directly in Python.
但我不是创建参数,而是说参数 A、B、C.为了在 Python 中使用它,我使用源创建了一个请求:
But instead of that I create parameters, let's say parameters A, B, C.
To use it in Python, I create a request with the source :
= Table.FromColumns({{A}, {B}, {C}}, {"parameterA", "parameterB", "parameterC"})
之后,我的参数可以通过 pandas
After that, my parameters are accessible in the dataset dict with pandas
parameterA = dataset['parameterA'][0])
parameterB = dataset['parameterB'][0])
parameterC = dataset['parameterC'][0])
希望对你有帮助
这篇关于Power BI 参数是否暴露给 Python 全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Power BI 参数是否暴露给 Python 全局变量
基础教程推荐
- 使用大型矩阵时禁止 Pycharm 输出中的自动换行符 2022-01-01
- 包装空间模型 2022-01-01
- PANDA VALUE_COUNTS包含GROUP BY之前的所有值 2022-01-01
- 求两个直方图的卷积 2022-01-01
- 修改列表中的数据帧不起作用 2022-01-01
- Plotly:如何设置绘图图形的样式,使其不显示缺失日期的间隙? 2022-01-01
- 无法导入 Pytorch [WinError 126] 找不到指定的模块 2022-01-01
- 在Python中从Azure BLOB存储中读取文件 2022-01-01
- 在同一图形上绘制Bokeh的烛台和音量条 2022-01-01
- PermissionError: pip 从 8.1.1 升级到 8.1.2 2022-01-01
