Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Measure with FILTER

Hello,

 

I am trying do write a measure using the function filter but it doesn't work fine. The code is :

 

Creusement hebdo TBM6 N =
(
CALCULATE(
[Creusement hebdo TBM6];
filter(TBM6__Date;TBM6__Date[ANNEE-SEMAINE]=[ANNEE-SEMAINE N TBM6])
)
)
 
TBM6__Date[ANNEE-SEMAINE] is a column of String values.
[ANNEE-SEMAINE N TBM6] is a String and contains "2020-S14" but doesn't match with TBM6__Date[ANNEE-SEMAINE]. However, if I replace [ANNEE-SEMAINE N TBM6] by its value "2020-S14" it is working successfully (see 3/)
 
1/Here the expression of [ANNEE-SEMAINE N TBM6]. Maybe it can help you to undestand my problem :
ANNEE-SEMAINE N TBM6 = convert(YEAR(max(TBM6__CAP_Pm[DATE])) &"-S" & if(WEEKNUM(max(TBM6__CAP_Pm[DATE]))<10;"0" & WEEKNUM(max(TBM6__CAP_Pm[DATE]));WEEKNUM(max(TBM6__CAP_Pm[DATE])));STRING)
 
2/ This test returns 1. I am sure that [ANNEE-SEMAINE N TBM6] contains exactly "2020-S14"
Creusement hebdo TBM6 N =
(
IF([ANNEE-SEMAINE N TBM6]="2020-S14";1;2)
)
 
3/ This test returns the right result (I changed [ANNEE-SEMAINE N TBM6] directly by "2020-S14"
Creusement hebdo TBM6 N =
(
CALCULATE(
[Creusement hebdo TBM6];
filter(TBM6__Date;TBM6__Date[ANNEE-SEMAINE]="2020-S14")
)
)
 
Have you got any idea of my problem ?
 
Thank you very much,
King regards

2 Replies