Quintiq file version 2.0
#parent: #root
Method RefreshData () id:Method_FormKpiQueryCompare_RefreshData
{
  #keys: '[146874.0.1482342599]'
  Body:
  [*
    // Queries the Kpi Tracker for the Kpi compare data
    compareLabel := DataHolderSeriesSelection.Data();
    compareLabels := selectset( DataHolderCompareLabels.Data(), Elements, val,
                                val.Label() = compareLabel );
    
    fixedLabels := selectset( DataHolderLabelFilters.Data(), Elements, val,
                              val.Label() <> compareLabel );
    
    set := GlobalStateKpiTracker.QueryDataFromServer( compareLabels, fixedLabels );
    
    GlobalStateKpiTracker.PropagateLabel( set, guard( compareLabel.Name(), '' ) );
    GlobalStateKpiTracker.PropagateTimeStamp( set, DataHolderTimeType.Data() );
    
    // Set relations
    traverse( set, SnapshotData.Value, v )
    {
      v.UI_CompareLabel( relset, select( compareLabels, Elements, s, s.Value() = v.UI_LabelValue() ) );
      v.UI_Kpi( relset, select( KpiTracker, MetaData, k, k.Name() = v.Name() ) );
    }
    
    DataHolderSnapshotData.Data( &set );
  *]
}
