Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Pivot table in widgets Example?

Hello,

I would like to ask, can please someone send example of pivot table through widgets?
I found api's and other staff, but I can't find any example, so I can work on it.

Thanks in advance

4 Replies
Stefan_Walther
Employee
Employee

Hi,

just for clarification purposes. What are you trying to achieve:

a) Create a pivot table object on the fly.

b) Create a completely custom pivot table.

Regards

Stefan

Not applicable
Author

Hi Stefan,

I want to build custom pivot table, with four dimensions and one measure, but with ability to hide, for example, two dimensions, they won't be shown on the table. For example, first and second dimension would be hidden, and 3 dimension would affect first column, and fourth dimension would affect first row of pivot table. Is this possible through widgets? I know that it can be done through visualization extensions, but I would like to make it work through widgets, because I see it as very good feature of sense 3.0., and I see that I can work on this side, because I like this very much. Thanks Stefan for reply, I hope that I will have answer, and I really appreciate what You are doing with widgets. Great Staff.

Regards,

Haris

Stefan_Walther
Employee
Employee

Hi,

hmm, that's really hard with Widgets. IMHO that's clearly something where you need some JavaScript, therefore I'd go for using the Visualization Extension concept.

Maybe have a look at the following extension, this might help as a starting point: GitHub - jgerardoc/QlikSense-Ext-JSPivotTable: Pivot Table extension for QlikSense

Hope this helps, at least a bit 😉

Regards

Stefan

davequinn
Contributor III
Contributor III

This code will give you a Pivot Table with one Dimension and up to 25 Measures (the limitation comes from the ng-repeat where I only went up to 25 and the ng-init which extends the qHypercubeDef size).

I'm not an angular expert - so there are probably better ways of doing this, but it works. Hope it helps!

Dave

<!-- Simple pivot table widget by dave.quinn@gmail.com -->
<div ng-init="data.model.enigmaModel.applyPatches([{qPath: '/qHyperCubeDef/qInitialDataFetch/0/qHeight', qOp: 'replace', qValue: '26'}])"></div>
<table class="table" border="1px">
	<tbody>
		<!-- for the first chart row only pull the titles out of Dimension and MeasureInfo arrays -->
		<tr data-ng-repeat="(key, val) in layout.qHyperCube.qDataPages[0].qMatrix[0]" ng-switch="" on="key">
			<th ng-switch-when="0">  
				{{layout.qHyperCube.qDimensionInfo[key].qFallbackTitle }} 
			</th>
			<th ng-switch-when="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25" ng-switch-when-separator="|">
				{{layout.qHyperCube.qMeasureInfo[key-1].qFallbackTitle }}
			</th>
			<!-- for other rows pull the values from qMatrix, note the exception for the first row again -->
			<th ng-switch-when="0" data-ng-repeat="row in layout.qHyperCube.qDataPages[0].qMatrix">
				{{ row[key].qText}}
			</th>
			<th ng-switch-when="0">Total</th>
			<td ng-switch-when="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25" ng-switch-when-separator="|" data-ng-repeat="row in layout.qHyperCube.qDataPages[0].qMatrix">			
				{{ row[key].qText}}
			</td>		  
			<td  ng-switch-when="1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25" ng-switch-when-separator="|">
				{{layout.qHyperCube.qGrandTotalRow[key-1].qText }}
			</td>
		</tr>
	</tbody>
</table>