| Quintiq file version 2.0 | 
| #parent: #root | 
| Method FilterDataOnSelectedLabels ( | 
|   shadow[KpiSnapshotSetData] queryResult, | 
|   structured[KpiLabelValue] labelFilters, | 
|   Boolean isLabelFilteringEnabled | 
| ) as String id:Method_GlobalStateKpiTracker_FilterDataOnSelectedLabels | 
| { | 
|   #keys: '[146874.0.1589192311]' | 
|   Body: | 
|   [* | 
|     // Copies the source data from DataHolderSnapshotSetData to DataHolderLabelFilterdSnapshots | 
|     // while filtering based on the selected Labels. | 
|     filter := ""; | 
|      | 
|     if ( not isnull( queryResult ) ) | 
|     {   | 
|       if ( isLabelFilteringEnabled ) | 
|       { | 
|         filters := construct( Strings ); | 
|          | 
|         traverse( labelFilters, Elements.Label, label ) | 
|         { | 
|           values := construct( Strings ); | 
|           traverse( label, Value, value, | 
|                     exists( labelFilters, Elements, selected, selected = value ) ) | 
|           { | 
|             values.Add( 'exists( object, Label, l, l.Name() = "' | 
|                         + label.Name() | 
|                         + '" and l.Value() = "' | 
|                         + value.Value() | 
|                         + '") ' ); | 
|           } | 
|           filters.Add( '(' + values.ToString( ' or ' ) + ')' ); | 
|         } | 
|         filter := filters.ToString( ' and ' ); | 
|         debuginfo( ' >>> Generated Label filter = ', filter ); | 
|       } | 
|     } | 
|      | 
|     return filter; | 
|   *] | 
| } |