====== Data Query / Expression Language ====== ===== Links ===== * [[https://nexus.exalead.com/repository/public-site/dse-best-practice/01-BestPractices/02-DataPerspectiveStudio/02-DataQueries/04-ExpressionLanguage/01-Content/|NETVIBES Consulting - DSE Best Pratices / Expression Language]] * [[https://help.3ds.com/2025x/english/DSDoc/DaaUserMap/daa-m-appendix-expression-language-sb.htm?contextscope=cloud&id=59de7db3d7e3457485b3af4910de8979|DS Doc - Expression Language]] ===== Examples ===== ==== Divers ==== transitionTuples : List> = List.range(startInclusive: 0, endExclusive: issue._history_event.length, step: 1 ) .map(index => issue._history_event[index] IN ["create", "promote","demote"]? {event:issue._history_event[index], datetime:issue._history_time[index],current:issue._history_state[index]} :NULL ).filter(x => x IS NOT NULL); durationsByTransition : List> = List.range(startInclusive: 1, endExclusive: transitionTuples.length, step: 1 ) .map(index =>{state: transitionTuples[index - 1].current, duration: Date.daysBetween(start: transitionTuples[index - 1].datetime, end: transitionTuples[index].datetime)}) + {state: transitionTuples[transitionTuples.length - 1].current, duration:Date.daysBetween(start: transitionTuples[transitionTuples.length - 1].datetime, end: Date.today())}; ==== stateful map() ==== snapshotTuples : List> = $Year_Weeks .map( initialState: issue.current , updateState: (x, previousState) => transitionsMap[x].current IS NOT NULL?transitionsMap[x].current:previousState , function: (x, currentState) => {week:x, current:x>=originatedWeek?currentState:NULL} ) .filter(x => x.current IS NOT NULL); ==== toMap ==== transitionsMap : Map> = List.range(startInclusive: 0, endExclusive: issue._history_event.length, step: 1 ) .map(index => issue._history_event[index] IN ["create", "promote","demote"]? {event: issue._history_event[index], datetime:issue._history_time[index], current: issue._history_state[index]} :NULL) .filter(x => x IS NOT NULL) .toMap( keyFunction: x => Date.format(date: x.datetime, format:"yyyy_ww") , valueFunction: x => x ); ==== Map.mapValues ==== //allDurationsByStatus// : Map>> durationsByStatus : Map = Map.mapValues( map: allDurationsByStatus , function: (list => list.sum(x => x.duration)) ) ; ou durationsByStatus : Map = allDurationsByStatus.mapValues(list => list.sum(x => x.duration));