Skip to content

fix: chart aggregation Function code + SemanticModel .platform path#29

Open
13w13 wants to merge 2 commits intoRussell-Shean:mainfrom
13w13:fix/chart-aggregation-function
Open

fix: chart aggregation Function code + SemanticModel .platform path#29
13w13 wants to merge 2 commits intoRussell-Shean:mainfrom
13w13:fix/chart-aggregation-function

Conversation

@13w13
Copy link
Copy Markdown

@13w13 13w13 commented Feb 28, 2026

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_type parameter 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_CODES lookup dict mapping aggregation type strings to their PBI SQExpr Function codes, and replaced both hardcoded 0 values.

_AGGREGATION_FUNCTION_CODES = {
    "Sum": 0, "Min": 1, "Max": 2, "Count": 3,
    "LongCount": 4, "DistinctCount": 5, "CountDistinct": 5,
    "Average": 6, "Avg": 6,
}

Backwards compatible — defaults to 0 (Sum) if an unknown aggregation type is passed.

2. SemanticModel .platform displayName (dashboard.py)

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", which can cause Power BI Desktop errors when the folder name doesn't match.

Fix: Changed to self.sm_platform_file_path and 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.

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.
@13w13
Copy link
Copy Markdown
Author

13w13 commented Feb 28, 2026

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!

13w13 added a commit to 13w13/powerbpy that referenced this pull request Feb 28, 2026
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>
13w13 added a commit to 13w13/powerbpy that referenced this pull request Feb 28, 2026
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>
@Russell-Shean
Copy link
Copy Markdown
Owner

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!

@13w13
Copy link
Copy Markdown
Author

13w13 commented Mar 2, 2026

Hey, happy traveling! Sure, let's have a quick zoom call :) Let's plan by email: contact.talon651@passinbox.com
cheers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants