3 Replies Latest reply: Dec 27, 2016 11:24 AM by Leonardo Contezini RSS

    Parameters in Variable with Set Analysis

    Leonardo Contezini

      Hi everyone,


      I have a Pivot Table in which I show 7 days in the horizontal dimension. If is there any date selected, the first day will be this one selected, and the others will be the 6 following days. In case of no date selected, the first day of the dimension will be today(), and the others will be the 6 future days.


      So, in order to sum what I need in each of these days of my calculated dimension, I'll thought about using a variable with parameters.


      My Date dimension is a variable (vDinamic_Dimension) as following:


      dual('$(=capitalize(weekday((today()-(vDay_Offset))))) - $(=date(today()-(vDay_Offset)))',1),
      dual('$(=capitalize(weekday((today()+1-(vDay_Offset))))) - $(=date(today()+1-(vDay_Offset)))',2),
      dual('$(=capitalize(weekday((today()+2-(vDay_Offset))))) - $(=date(today()+2-(vDay_Offset)))',3),
      dual('$(=capitalize(weekday((today()+3-(vDay_Offset))))) - $(=date(today()+3-(vDay_Offset)))',4),
      dual('$(=capitalize(weekday((today()+4-(vDay_Offset))))) - $(=date(today()+4-(vDay_Offset)))',5),
      dual('$(=capitalize(weekday((today()+5-(vDay_Offset))))) - $(=date(today()+5-(vDay_Offset)))',6),
      dual('$(=capitalize(weekday((today()+6-(vDay_Offset))))) - $(=date(today()+6-(vDay_Offset)))',7),
      dual('$(=capitalize(weekday((today()+7-(vDay_Offset))))) - $(=date(today()+7-(vDay_Offset)))',8),


      And my expression is:


      if( $(vDinamic_Dimension)=1,
      if( $(vDinamic_Dimension)=2,
      if( $(vDinamic_Dimension)=3,
      if( $(vDinamic_Dimension)=4,
      if( $(vDinamic_Dimension)=5,
      if( $(vDinamic_Dimension)=6,
      if( $(vDinamic_Dimension)=7,


      Here is my question:

      I want to know what do I need to use inside de variable vOrder_Quantity, in order to sum the days for each value of the vDinamic_Dimension. I thought about something like this, but it's not working and returns null values.


      vOrder_Quantity =
      sum({$<Day = {'$(=today()+$1)'}>} [Order Quantity])


      Here is my variable for Day Offset:


      vDay_Offset = 
      num(YearEnd(if(count(GetFieldSelections(Date)) = 0, today(), Date)) - YearStart(if(count(GetFieldSelections(Date)) = 0, today(), Date)),'#.##0')*(year(today()-1) - max(Year))  // Offset Year
      day(MonthEnd(if(count(GetFieldSelections(Date)>0, Date, today())))*(month(today()-1) - if(count(GetFieldSelections(Date))=0,month(today()-1),max(Month)))   // Offset Month
      day(today()-1) - if(count(GetFieldSelections(Date))=0,day(today()-1),max(Day))    //Offset day