a!columnChartField( label: "Année", labelPosition: "JUSTIFIED", categories: a!forEach( items: local!periodes[local!selectedPeriod].weeks.week, expression: "S" & fv!item ), series: a!forEach( items: local!uPerWeekPeriode, expression: a!localVariables( local!cBrandId: fv!item.cBrandId, a!chartSeries( label: fv!item.cBrand, data: if( contains(fv!item.cBrandId, ri!selectedUs), fv!item.uPerWeeks, {} ), links: a!forEach( items: local!periodes[local!selectedPeriod].weeks, expression: a!dynamicLink( saveInto: { a!save(ri!filteredYear,tointeger(fv!item.year)), a!save(ri!filteredWeek,fv!item.week), a!save(ri!filteredStatus,cons!STATUT), a!save(ri!filteredCBrand,local!cBrandId), a!save(ri!displayPList,true) } ) ) ) ) ), yAxisMax: local!topAxisUb, stacking: "NONE", showLegend: true, showTooltips: true ),
I wanted to filter the chart to display only "selected Us". In othrer words, only contains" selected Us".
Discussion posts and replies are publicly visible
Can you post the screenshot of chart as well, its hard to imagine?
Is the error referencing a line number in the code? The error itself is simply saying it can't compare two different types of data. You need to cast one (or both)( of them to a common data type before they can be compared. Since you mention 'selected Us' my guess is the error is in Line 15 in your code block above.
line number 15 at function 'contains' [line 15]: Invalid types, can only act on data of the same type (Any Type, Type CDT)
Sorry, the chart doesn't display with this. I don't have chart yet
Yup. So as already mentioned:
"The error itself is simply saying it can't compare two different types of data. You need to cast one (or both) of them to a common data type before they can be compared."
As a best practice, whenever you are using comparision functions like contains() and wherecontains() always typecast them. Especially when you are dealing with local variables because they wont have any datatype by default. In the above case, you can rewrite the above contains logic like this (assuming they are integers):contains(
tointeger(index(fv!item, "cBrandId", "")),
tointeger(ri!selectedUs)
)