3 Replies Latest reply on Jul 20, 2016 6:26 AM by Luciano Vasconcelos

    Calculating MTD-YTD Values

    Venkat Madan

      Hi Everyone,


      I have a doubt regarding the calculation of MTD-YTD values in Tableau.


      For example if i have the following details year, month, salesrep, product, sales. And i want to show the MTD, YTD values in tableau.


      Condition is A Salesrep might or might not have done sales in a particular month for a particular product. But i want to display the respective MTD, YTD values for the salesrep in the Table and i want all the salesrep or products need to be displayed at all months irrespective whether the sales is there or not when there is a month filter.


      Is it possible to do directly in tableau?

        • 1. Re: Calculating MTD-YTD Values
          Naveen Agarwal

          Can you post your data or a sample set?

          • 2. Re: Calculating MTD-YTD Values
            Tiago Ferrucio

              You can created parameter filter and use in your Calculated filter.


              Ex. Parameter


              And my calculated field.


            Case [Filtro]

            when "YTD" then

                    sum(If [Período]<= [Referência] and Datediff('year',[Período],[Referência])=0 then [Number of Records] end)

                when "MAT" then

                    sum(If [Período] >= Dateadd('month', -11, [Referência]) and [Período]<= [Referência] then [Number of Records] end)

                when "MONTH" then

                    sum(If [Período] = [Referência] then [Number of Records] end)



            If you don't understand, post your data.



            1 of 1 people found this helpful
            • 3. Re: Calculating MTD-YTD Values
              Luciano Vasconcelos

              You have two different problems.

              If you want all REPs vs Products in all months i suggest you build a table with colums ID_REP an ID_Product and use it on left side of the data source.

              Doing this you'll have all combinations REP/Products and all the sales.

              About periods you can adapt Tiago's answer.