Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hello,
I want to create a custom waterfall chart. Found a beautiful piece of code on github for exactly this purpose.
Everytime I see python script used in a visualization the variables are always defined as columns. My waterfall chart should be build based on measures instead of columns.
I already put them in the "Values" pane but I'm having trouble how to incorporate those into the python code. I need something like this:
"target = [Month Target]" where the name between the brackets is measures name of course.
Any ideas?
Solved! Go to Solution.
Hi @MKMA,
Thank you for reaching out to the Microsoft Fabric Forum Community.
Python visuals in Power BI treat incoming data from the Fields/Values pane as a Pandas DataFrame, but measures behave differently than columns when passed into a Python visual. Measures Do not become standalone variables, they're aggregated and usually show up as part of a DataFrame row.
Use SUMMARIZE to simulate rows
create a table with measures as columns in Power BI using DAX like this:
WaterfallTable =
SUMMARIZE(
'YourBaseTable',
'YourBaseTable'[Category],
"Target", [Month Target],
"Actual", [Month Actual],
)
Then you can add this calculated table to the Python visual like a regular dataset, and reference like:
target = dataset['Target']
actual = dataset['Actual']
If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.
Thank you & regards,
Prasanna Kumar
Hi @MKMA,
Just a gentle reminder — has your issue been resolved? If so, we’d be grateful if you could mark the solution that worked as Accepted Solution, or feel free to share your own if you found a different fix.
This not only closes the loop on your query but also helps others in the community solve similar issues faster.
Thank you for your time and feedback!
Best,
Prasanna Kumar
Hi @MKMA,
We wanted to kindly check in to see if everything is working as expected after trying the suggested solution. If there’s anything else we can assist with, please don’t hesitate to ask.
If the issue is resolved, we’d appreciate it if you could mark the helpful reply as Accepted Solution — it helps others who might face a similar issue.
Warm regards,
Prasanna Kumar
Hi @MKMA,
Just following up to see if the solution provided was helpful in resolving your issue. Please feel free to let us know if you need any further assistance.
If the response addressed your query, kindly mark it as Accepted Solution and click Yes if you found it helpful — this will benefit others in the community as well.
Best regards,
Prasanna Kumar
Hi @MKMA,
Thank you for reaching out to the Microsoft Fabric Forum Community.
Python visuals in Power BI treat incoming data from the Fields/Values pane as a Pandas DataFrame, but measures behave differently than columns when passed into a Python visual. Measures Do not become standalone variables, they're aggregated and usually show up as part of a DataFrame row.
Use SUMMARIZE to simulate rows
create a table with measures as columns in Power BI using DAX like this:
WaterfallTable =
SUMMARIZE(
'YourBaseTable',
'YourBaseTable'[Category],
"Target", [Month Target],
"Actual", [Month Actual],
)
Then you can add this calculated table to the Python visual like a regular dataset, and reference like:
target = dataset['Target']
actual = dataset['Actual']
If you find this response helpful, please consider marking it as the accepted solution and giving it a thumbs-up to support others in the community.
Thank you & regards,
Prasanna Kumar
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
58 | |
56 | |
56 | |
38 | |
29 |
User | Count |
---|---|
75 | |
62 | |
45 | |
40 | |
40 |