I have created a crosstab report that utlises a measure [Sales]. I wish to calculate a variance number measure [Variance] between the first selected period and the last selected period. I can correctly calculate the variance using the following formula.
[Variance] = ([Sales] Where (([Cal. year / month]="04.2014"))-([Sales] Where ([Cal. year / month]="03.2014")))
[Cal. year/ month] represents a dimension.
[Sales] represents a number measure.
The crosstab references a Bex query.
I wish to make the periods "03.2014" and "04.2014" dynamic, such that they reference the first and last selections from the BEx query.
I have created a string measure [Period Last] = Last([Cal. year / month]). When placing this string measure in the report a value of 04.2014 is returned.
I then modify the variance number measure [Variance] to the following:
[Variance]=([Sales] Where (([Cal. year / month]=[Period Last]))-([Sales] Where ([Cal. year / month]="03.2014")))
The incorrect variance is calculated, whereby the calculation is summing all(for both periods in this example) periods [Sales] to 04.2014 and then subtracting period 03.2014, rather than just taking the last period [Sales] being 04.2014 and subtracting period [Sales] for period 03.2014.