Quintiq file version 2.0
#parent: #root
Method FilterDataOnSelectedKpis (
  structured[KpiMetaData] filterKpis,
  KpiLabel series,
  Boolean isLastSnapshotChecked
) as String id:Method_Kpi_GlobalState_FilterDataOnSelectedKpis
{
  #keys: '[146874.0.1589142731]'
  Body:
  [*
    // Sets the filter on the KpiValues list to match the selected KPIs and the 
    // LastSnapshotOnly checkbox.
    filter := "";
    
    if ( not isnull( filterKpis ) and filterKpis.Size() > 0 )
    {
      filters := construct( structured[String] );
      traverse( filterKpis, Elements, kpi ) 
      {
        filters.Add( "object.Name() = " + kpi.Name().AsQUILL() );
      }
      filter := "( " + filters.ToString( ' or ' ) + " )";
      
      
      if ( isLastSnapshotChecked and not isnull( series ) ) 
      {
        filter := filter + " and ( object.UI_IsLast() ) "
      }
      debuginfo(' >>> Setting filter to ' , filter );
    }
    
    return filter;
  *]
}
