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 全局变量


- 沿轴计算直方图 2022-01-01
- padding='same' 转换为 PyTorch padding=# 2022-01-01
- 使用Heroku上托管的Selenium登录Instagram时,找不到元素';用户名'; 2022-01-01
- 分析异常:路径不存在:dbfs:/databricks/python/lib/python3.7/site-packages/sampleFolder/data; 2022-01-01
- 如何在 Python 的元组列表中对每个元组中的第一个值求和? 2022-01-01
- pytorch 中的自适应池是如何工作的? 2022-07-12
- 如何将一个类的函数分成多个文件? 2022-01-01
- python check_output 失败,退出状态为 1,但 Popen 适用于相同的命令 2022-01-01
- python-m http.server 443--使用SSL? 2022-01-01
- 如何在 python3 中将 OrderedDict 转换为常规字典 2022-01-01