fix: chart aggregation Function code + SemanticModel .platform path#29
fix: chart aggregation Function code + SemanticModel .platform path#2913w13 wants to merge 2 commits intoRussell-Shean:mainfrom
Conversation
chart.py hardcoded "Function": 0 (Sum) in both the Y-axis projection and the sort definition, ignoring the y_axis_var_aggregation_type parameter entirely. This meant all charts defaulted to Sum aggregation regardless of what was passed (Count, DistinctCount, Average, etc.). Added _AGGREGATION_FUNCTION_CODES mapping dict and replaced both hardcoded values with a lookup. PBI SQExpr Function codes: 0=Sum, 1=Min, 2=Max, 3=Count, 4=LongCount, 5=DistinctCount, 6=Average
Dashboard.create() used self.platform_file_path (Report .platform) instead of self.sm_platform_file_path when updating the SemanticModel .platform file. This left the SemanticModel displayName as "blank_template", causing Power BI Desktop to show "Not enough memory" errors when the folder name didn't match the displayName.
|
Hi Russell! I'm 13w — I work in data/information management and recently started using powerbpy to generate Power BI dashboards programmatically. Really cool project, exactly what I was looking for. I've been building multi-page dashboards with various aggregation types and ran into these two bugs, so I figured I'd contribute the fixes back. I've forked the repo and plan to keep using and developing on my side — I code with LLM assistance (not a developer by trade), so I can iterate pretty fast on features and fixes. Happy to submit more PRs for other issues I've spotted (lazy imports, f-string fix, encoding). Let me know if you have any preferences on how you'd like contributions structured! |
List all visual types, formatting options, data modeling features, and bug fixes added in this fork. Link to upstream PRs Russell-Shean#29-Russell-Shean#32. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Explain why this fork exists (experimental LLM-assisted PBI workflow), list all added visual types, formatting options, data modeling features, and bug fixes. Link to upstream PRs Russell-Shean#29-Russell-Shean#32. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hi 13w, Glad you found the project and have been using it! It's exciting to see the tool being used in the real world! I'm currently traveling, so it may be a few more days before I'm able to approve the pull requests. Please contribute any bug fixes and new features back to the main branch, that would be super appreciated! I'm curious to learn more about how you've been using the project and your development process. If you are open to I'd be happy to schedule a quick zoom call to chat. I can also talk a bit more about my plans for project. I think using AI is great to speed up development, but I think it will require me to develop more robust testing for this project, (something I should do anyways 😅 ). I think it might be helpful to talk a bit about that before I start integrating significant amounts of llm generated code. If you preferred to maintain anonymity, no worries; I'll try to put all of that in writing too. I just thought at this stage, without a ton of contributors, a chat might be quicker! |
|
Hey, happy traveling! Sure, let's have a quick zoom call :) Let's plan by email: contact.talon651@passinbox.com |
Summary
Two bug fixes for issues encountered when building dashboards with multiple aggregation types.
1. Chart aggregation Function code (
chart.py)y_axis_var_aggregation_typeparameter was accepted but ignored —"Function": 0(Sum) was hardcoded in both the Y-axis projection and the sort definition. All charts defaulted to Sum regardless of the aggregation type passed.Fix: Added
_AGGREGATION_FUNCTION_CODESlookup dict mapping aggregation type strings to their PBI SQExpr Function codes, and replaced both hardcoded0values.Backwards compatible — defaults to
0(Sum) if an unknown aggregation type is passed.2. SemanticModel
.platformdisplayName (dashboard.py)Dashboard.create()usedself.platform_file_path(Report.platform) instead ofself.sm_platform_file_pathwhen updating the SemanticModel.platformfile. This left the SemanticModeldisplayNameas"blank_template", which can cause Power BI Desktop errors when the folder name doesn't match.Fix: Changed to
self.sm_platform_file_pathand used a separate variable name to avoid confusion.Testing
Tested with a multi-page dashboard using 4 CSV datasets and DAX measures. Charts now correctly render with DistinctCount, Count, and Average aggregations.