Reputation: 1227
I have the following expression that is supposed to convert months into quarters. However, when I run the report, only the first and fourth quarter show up. Could someone please take a look at my expression to see if it is correct? I have never created an SSRS report or expression before.
=IIf(Fields!Month.Value/3 <= 1, 1, IIf(Fields!Month.Value/3 > 1 AND Fields!Month.Value <=2, 2, IIf(Fields!Month.Value > 2 and Fields!Month.Value <= 3, 3, 4)))
Upvotes: 0
Views: 96
Reputation: 2332
Did you consider using =DatePart(DateInterval.Quarter, Fields!Month.Value)
?
Upvotes: 1
Reputation: 399
This works:
=IIF((Fields!Month.Value/3)<=1,1,
(IIF((Fields!Month.Value/3)<=2,2,
(IIF((Fields!Month.Value/3)<=3,3,4)))))
Upvotes: 0
Reputation: 20654
Suppose Fields!Month.Value
is 4. That gives:
=IIf(4/3 <= 1, 1, IIf(4/3 > 1 AND 4 <=2, 2, IIf(4 > 2 and 4 <= 3, 3, 4)))
Obviously, 4/3 <= 1
is false, 4/3 > 1 AND 4 <=2
is false, and 4 > 2 and 4 <= 3
is false, meaning that the quarter is 4. Incorrect.
Try this:
int((Fields!Month.Value - 1) / 3) + 1
Upvotes: 1