Power BI参数是否向Python全局变量公开 [英] Does Power BI parameters are exposed to Python globals

查看:184
本文介绍了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脚本的上下文中声明可访问的所有globals变量,但我无法查找与参数有关的任何内容。我可以看到数据集。

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全局变量公开的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆