Forum Discussion
FICO
8 years agoCommunity Manager
Filter vdl-table display to nonzero rows in FICO Insight application
This FICO Xpress Optimization forum might not be the right area for this question, but I don't see a forum for FICO Insight.
I have a FICO Insight application that displays a Mosel entity on the web-based user-interface using a vdl-table. The Mosel entity is mostly zeros though. What's the easiest way to filter the table for the rows that contain at least one non-zero? I'm pretty sure the answer involves vdl-index-filter.
For example, I have the Mosel entities:
Materials_Description: dynamic array(Plants, Materials) of string
rawinput: dynamic array(Plants, Materials, Times) of mpvar
and one of my vdl-page views contains:
<vdl-table page-mode="paged" show-filter="true">
<vdl-table-column entity="Materials_Description"/>
<vdl-table-column entity="rawinput"
heading="=col.label"
vdl-repeat="=col in scenario.entities.Times">
<vdl-index-filter set="Times" value="=col.value"/>
</vdl-table-column>
</vdl-table>
then I get a nice table with the Times set pivoted, but there are a lot of rows in the table that are entirely zero. How can I filter out those rows?
1 Reply
- FICOCommunity Manager
Ok, I found a solution that uses the "row-filter" attribute of the vdl-table.
I modified my VDL file to:
<script>
function absAdd(a, b) {
return Math.abs(a) + Math.abs(b);
}
function nonZeroRow (rowData, indices, otherColumnsToIgnore) {
// return true if the sum of the data in the row is greater than zero
// the sum excludes some of the first columns (any index columns plus otherColumnsToIgnore)
// otherColumnsToIgnore should be an integer
var rowStart = indices.length + otherColumnsToIgnore,
rowEnd = rowData.length;
return rowData.slice(rowStart, rowEnd).reduce(absAdd, 0) > 0;
}
</script>
<vdl-table page-mode="paged" show-filter="true"
row-filter="=nonZeroRow(rowData, indices, 1)">
<vdl-table-column entity="Materials_Description"/>
<vdl-table-column entity="rawinput"
heading="=col.label"
vdl-repeat="=col in scenario.entities.Times">
<vdl-index-filter set="Times" value="=col.value"/>
</vdl-table-column>
</vdl-table>
Related Content
Related Content
vdl-table default column sort
vdl-table is sorted ascending by the first column by default and the user can easily change this by clicking the column they want to sort by, but how can I change the default sort so all users initia...6 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum3 unread comments3 unread0Views0likes3CommentsHow to display VDL-TABLE with entity values across scenarios, relative to the first selected scenario
I have these Mosel entities: KPIs: set of string SummaryKPI: array(KPIs) of real And I have a VDL view with: <vdl-table vdl-if="=scenarios.length > 1"> <vdl-table-column ...7 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum2 unread comments2 unread0Views0likes2CommentsHow to refresh vdl-table in JavaScript after adding a new row?
I want to replace the +- button coming with the addrow-autoinc option for vdl-table because we need to perform certain value changes when a new row is added. I think I managed in my JavaScript code (...3 years agoPlace FICO® Xpress Optimization ForumFICO® Xpress Optimization Forum1 unread comment1 unread0Views0likes1Comment