Power BI 参数是否暴露给 Python 全局变量

Does Power BI parameters are exposed to Python globals(Power BI 参数是否暴露给 Python 全局变量)
本文介绍了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.

但我不是创建参数,而是说参数 ABC.为了在 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 全局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

python arbitrarily incrementing an iterator inside a loop(python在循环内任意递增迭代器)
Joining a set of ordered-integer yielding Python iterators(加入一组产生 Python 迭代器的有序整数)
Iterating over dictionary items(), values(), keys() in Python 3(在 Python 3 中迭代字典 items()、values()、keys())
What is the Perl version of a Python iterator?(Python 迭代器的 Perl 版本是什么?)
How to create a generator/iterator with the Python C API?(如何使用 Python C API 创建生成器/迭代器?)
Python generator behaviour(Python 生成器行为)