Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hello,
As per https://github.com/Microsoft/PowerBI-visuals/wiki/DataView-Introduction Table DataView should carry totals within it.
But I tried both in desktop and web version but it dosent workout for me. This property is always undefined.
I want to get the totals for column (when user selects Average or SUM or Minimum or Maximun etc).
I also looked into the aggregates but it gives only min & max. Subtotal is always undefined.
I am using below capabilities
dataRoles: [{ displayName: 'Values', name: 'Values', kind: VisualDataRoleKind.GroupingOrMeasure }], dataViewMappings: [{ table: { rows: { for: { in: 'Values' }, dataReductionAlgorithm: { window: { count: 100000 } } }, rowCount: { preferred: { min: 1 } } }, }],
Example code:
public update(options: VisualUpdateOptions) { options.dataViews[0].table.totals; options.dataViews[0].table.columns[0].aggregates.min; options.dataViews[0].table.columns[0].aggregates.max options.dataViews[0].table.columns[0].aggregates.subtotal; }
Any Ideas?
Hello,
I' ve created a simple custom visual showing a grid, however I can't find how to make it show the totalrow.
Searching the internet I stumbled upon this post. It's from a while ago, maybe you guys have some more insights now?
Thanks in advance!
Frank
The totals aren't supported by Power BI.
We'll propose this idea to Power BI Custom Visuals API team.
Ignat Vilesov,
Software Engineer
Microsoft Power BI Custom Visuals
Well, I have some disappointing news for you:
In order for the dataview to carry the totals object within it, you have to explicitly ask for it. It is done by implementing a "customizeQuery(options: CustomizeQueryOptions): void" function and setting it as your visual's IVisualPlugin implementation's customizeQuery property. The bad news is that in order to do so, you have to access an API that is blocked by the custom visuals sandboxing. I.e. once you export you visual and use it in Power BI Service, it won't be able to access its IVisualPlugin object.
If you'd like to give it a try, it can be done as follows:
1. Implement a customizeQuery() method(Example is a bit simplified)-
public static customizeQuery(options: CustomizeQueryOptions): void { var dataViewMapping = options.dataViewMappings[0]; if (!dataViewMapping || !dataViewMapping.table || !dataViewMapping.metadata) return; var dataViewTableRows: data.CompiledDataViewListRoleMapping = <data.CompiledDataViewListRoleMapping>dataViewMapping.table.rows; (<data.CompiledDataViewRoleForMapping>dataViewTableRows.select[1]).for.in.subtotalType = data.CompiledSubtotalType.Before; // **(Read notes)** }
Notes:
2. In your visual's init() method, get its IVisualPlugin object and set its customizeQuery property to the function you created-
visualPluginFactory.create().getPlugin("YourVisual1464287088710").customizeQuery = YourVisual.customizeQuery;
Notes:
3. Now, once your visual is initialized, the function will be invoked by the environment and the totals object will be delivered in the subsequent invocation of update().
A very thin silver lining is that if you'd donate your visual to the custom visuals gallery, it won't be sandboxed, since Microsoft reviews the code of donated visuals prior to putting them in the gallery.
Final notes:
Thanks a lot for the wonderful insight.
Glad I could be of assistance.
Also, I just posted an idea regarding this issue to Power BI Ideas. Here's the link, in case you'd like to give it your vote-
User | Count |
---|---|
17 | |
11 | |
5 | |
4 | |
3 |