in packages/tablesorter-powerbi/src/ConfigBuilder.ts [415:445]
export function calculateRankingInfo(dataView: powerbi.DataView) {
"use strict";
if (dataView && dataView.table && dataView.table.rows) {
const rankingColumnInfo = dataView.table.columns
.map((n, i) => ({
column: n,
idx: i,
}))
.filter(n => n && isRankColumn(n.column))[0]; // Do the filter after, so the index is retained correctly
if (rankingColumnInfo) {
const values = Object.keys(
dataView.table.rows
.reduce((a, b) => {
const rankValue = b[rankingColumnInfo.idx] as string;
if (rankValue !== null && rankValue !== undefined) { // tslint:disable-line
a[rankValue] = 1;
}
return a;
}, {}))
.map(n => parseFloat(n))
// Just an additional safety net, just in case for some reason invalid data gets through
.filter(n => !isNaN(n))
.sort(naturalSort);
return {
column: rankingColumnInfo.column,
values,
};
}
}
}