问题
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.
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
回答1:
I've finally find a solution to my problem. So I didn't figure out how to get parameters directly in 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"})
After that, my parameters are accessible in the dataset dict with pandas
parameterA = dataset['parameterA'][0])
parameterB = dataset['parameterB'][0])
parameterC = dataset['parameterC'][0])
Hope it helps you
来源:https://stackoverflow.com/questions/56461168/does-power-bi-parameters-are-exposed-to-python-globals