Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Can I use dimension value in setAnalysis in expression?

I want to do something like this

=Sum( {1<Date={$(=date($(vWeekStart) + Num(DayName)) )}>} Sales)

Where DayName is a dimension in my chart and weekstart is a variable.

If I use just the dimension in expression it gives me all the values, but it does not seem to work in setAnalysis like this. Can anybody tell me why?

2 Replies
Anonymous
Not applicable
Author

Hi Maulik,

You're gonna run into problems here since the Num(DayName) is evaluated over all available DayName and not just the current dimension value and will return null if you have more than one DayName. Why not just pull the Week and Day name as fields from the info you have in Date on the script side and use the DayName as a dimension.

Something along the lines of:

Load
week(Date) as Week,
Date,
text(date(Date,'WWWWWW')) as Dayname;
Load
date(Today()+Recno()) as Date
autogenerate 50;


And then write an expression along the lines of Sum({1<Week={$(=vWeek)}>} Sales) (Not that I have a sales field in the example thought).



Not applicable
Author

Hmmmm it's a bit tricky... so in the set expression it won't be unique ? because my dimension itself is DayName and if I just use Num(DayName) in expression it does print unique numbers (0,1,2,3.....)

What I want to do is take a particular date from variable and add Num(DayName) (i.e. 0, 1, 2, 3) to that date to get the whole week dates. Having dates make sure that my sum on sales is going to be correct.

Plotting weekly data is difficult because in Norway calender week number 1 can belong to few dates in Jan and few dates of Dec in the same year. That's why I am using the above approach.