YTQ, QTD, MTD and WTD

    Year, Quarter, Month and Week To Date are the common analysis that I seen many applications. I will share the expression to do here

    First to do this your data model should have the DateField in number format by applying floor

    Similar to this

    Floor(DateField) AS DateNum //it will gives you one whole number to represent date

    YTD - Year To Date

    A date should be selected and it will look for the Starting date of the year to the selected date.

    Ex: date selected is 21-03-2014 then YTD is 01-01-2014 to 21-03-2014

    Expression would be

    Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num(YearStart(Max(DateNum))))<=$(=Max(DateNum))"}>} Sales)

     

    QTD- Quarter to Date

    In the place of year use Quarter

    Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num(YearStart(Max(DateNum))))<=$(=Max(DateNum))"}>} Sales)

     

    MTD- Month to Date

    Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num(MonthStart(Max(DateNum))))<=$(=Max(DateNum))"}>} Sales)

     

    WTD- Week to Date

    Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num(WeekStart(Max(DateNum))))<=$(=Max(DateNum))"}>} Sales)

     

    if you want you can set a variable value as 'Year', 'Month', 'Quarter', 'Week', lets say vToDate and go with single chart and single expression

    Sum({<Year=, Month=, Quarter=, Week=, DateField=, DateNum={">=$(=Num($(=vToDate& 'Start(Max(DateNum))')))<=$(=Max(DateNum))"}>} Sales)

     

    Will keep your expression simple

     

    Regards,

    Celambarasan