5 Replies Latest reply: Jan 31, 2010 5:01 PM by Angelos Vlisidis RSS

    YTD Calculation in a Straight Table

      I am trying to calculate the YTD amount in a straight table where my time dimension is the rows (see table below). I cannot use any of the "Accumulation" methods due to issues with combining calculations on data that does not require accumulation (Balance Sheet vs Income Statement Accounts).

      I don't want to use a date selection because it needs to calculate for every date in the table. Any time I use a set analysis on my Period field (i.e. Period = {'>= yearstart(Period)'} ) I just get the calculation for the current month and not a YTD number. I can only find examples where the date is not a dimension and/or someone is selecting the date. I can do that, I just can't find the right code for this.

      Convert column 'B' below to Column 'C'.

      Thanks in advance for your help,


      PeriodCurrent MonthYTD Calc
      (How in QV?)
      NET INCREASE IN CASHPrev YTDEnding Cash Calc

        • YTD Calculation in a Straight Table
          Neil Miller

          Can you use Above()?

          If(Above([Current Month]), Above([YTD Calc]) + [Current Month], [Current Month])

          This expression is called YTD Calc, if you want to use a different label, you need to change Above([YTD Calc]) in the expression to reflect your YTD expression label.

            • YTD Calculation in a Straight Table

              I tried the Above() function and it just gives me the sum of the previous month plus the current month. It does not roll forward. In my table, the [YTD Calc] column is the formula that I need, so I do not have anything to substitute in your example. That is the missing formula I can't seem to figure out without using the "Accumulation" function.

              • YTD Calculation in a Straight Table

                I figured it out. After much searching and trying various topics, I used a combination of the rangesum and above functions. Here is what I got to work:


                where the above function allows you to choose how many row backs to start - in this case zero (0). Then I use my Period to tell it how many rows back to go (Num(Month(Period)). This way, when you get to a new year, it will automatically only go back one month and not carry a balance forward from last year (since Num(Month(Period)) = 1).

                This will overcome any issues with the "Full Accumulation" options in a table when you have multiple years.

                Thanks for the help.







                  • YTD Calculation in a Straight Table
                    Angelos Vlisidis

                    Hello to all,

                    I have the same problem with YTD calculations. The solution proposed by Kevin works fine only when month is the last (or the only) level in the chart. In my case below Month there is Week and Day Level. When Week&Day are collapsed everything is OK. When I expand a month to go to the week level the function returns the sum([Actual]).

                    I cannot believe that is so difficult to do a simple multivelel YTD in qlik.



                      • YTD Calculation in a Straight Table
                        Angelos Vlisidis

                        I found a workaround to this problem by using dimensionality() function thanks to http://community.qlik.com/forums/t/25153.aspx.

                        I have a pivot table with Market-Month-Week-Day dimensions. When everything is collapsed dimensionality() returns 1. When Market is expanded to Months returns 2 e.t.c

                        so the solution is:


                        if (dimensionality() = 2, //MONTH LEVEL
                        if(dimensionality() = 3, //WEEK LEVEL
                        if(dimensionality() = 4, //DAY LEVEL
                        sum(CY_AMOUNT) //Market Level


                        I don't know what the performace penalty is but it works at least!

                        I am looking now to find a more elegant solution by using set analysis.