1

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

Benjamin Audet
  • 463
  • 3
  • 12

1 Answers1

2

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

Benjamin Audet
  • 463
  • 3
  • 12
  • long shot that you are still around to answer, but, where does "= Table.FromColumns({{A}, {B}, {C}}, {"parameterA", "parameterB", "parameterC"})" go? Is it in the Power BI Python script editor? – MPJ567 Sep 25 '20 at 17:33
  • 1
    It's in the in input of the table right above it (like if you were typing a formula on Excel). Not in the python editor, – Benjamin Audet Dec 17 '20 at 13:28