Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions src/powerbpy/chart.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@

from powerbpy.visual import _Visual

# Power BI SQExpr aggregation Function codes
_AGGREGATION_FUNCTION_CODES = {
"Sum": 0,
"Min": 1,
"Max": 2,
"Count": 3,
"LongCount": 4,
"DistinctCount": 5,
"CountDistinct": 5,
"Average": 6,
"Avg": 6,
}

class _Chart(_Visual):
"""A subset of the visual class, this class represents charts"""

Expand Down Expand Up @@ -133,7 +146,7 @@ def __init__(self,
"Property": y_axis_var
}
},
"Function": 0
"Function": _AGGREGATION_FUNCTION_CODES.get(y_axis_var_aggregation_type, 0)
}
},
"queryRef": f"{y_axis_var_aggregation_type}({data_source}.{y_axis_var})",
Expand All @@ -157,7 +170,7 @@ def __init__(self,
"Property": y_axis_var
}
},
"Function": 0
"Function": _AGGREGATION_FUNCTION_CODES.get(y_axis_var_aggregation_type, 0)
}
},
"direction": "Descending"
Expand Down
12 changes: 6 additions & 6 deletions src/powerbpy/dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,18 +179,18 @@ def create(cls, file_path):

## Semantic model folder ----------------------------------------------------------------
# .platform file
with open(self.platform_file_path,'r', encoding="utf-8") as file:
platform_file = json.load(file)
with open(self.sm_platform_file_path,'r', encoding="utf-8") as file:
sm_platform_file = json.load(file)

# modify the display name
platform_file["metadata"]["displayName"] = f'{self.report_name}'
sm_platform_file["metadata"]["displayName"] = f'{self.report_name}'

# update the unique UUID
platform_file["config"]["logicalId"] = self.sm_logical_id
sm_platform_file["config"]["logicalId"] = self.sm_logical_id

# write to file
with open(self.platform_file_path,'w', encoding="utf-8") as file:
json.dump(platform_file, file, indent = 2)
with open(self.sm_platform_file_path,'w', encoding="utf-8") as file:
json.dump(sm_platform_file, file, indent = 2)

return self

Expand Down