8 Replies Latest reply on Sep 18, 2018 8:26 AM by Salma Hassan

    Problem with difference calculation for many observations

    Salma Hassan

      Dear Tableau community,

       

      I'm trying to make my very first time series analysis for some data related to my work.

      Long story short, I'm comparing a (Total Views) for different videos (Video ID) over a period of time (Age).

      So the thing I was trying to do is to calculate the 'difference' instead of 'sum' for the Total Views attribute, which supposed to, according to my understanding, calculate the difference for each video according to its previous value, not according to all other videos. But from what I see I think it's doing the later thing instead of the former and I can't figure out why.

      What makes me think like that is the calculated difference for my data should never be in negative due to the incremental behavior of Total Views (Figure 1). Moreover, when I Keep Only one video, it calculate the difference perfectly (Figure 2).

       

      total views - age (2).png

      (Figure 1)

       

      total views - age1.png

      (Figure 2)

       

      So any help to understand how the thing works would be totally appreciated.

      I'm new to the whole analysis and tableau so I'm struggling to understand things clearly.

      (This is my first question here and tried to be as clear as possible as I can, so please note any other information I should have mentioned in the question.)

       

      Thanks in advance.

        • 1. Re: Problem with difference calculation for many observations
          Jim Dehner

          Good morning

          First welcome to the forum -  see then link on how to make the most effective use of the forum  Getting Started in the Forums

           

          now to your question - would really need to see your twbx workbook with the data to give you a good answer but there is a table calculation that will do this

           

           

           

          in text table form it does this

           

          as a line chart  it looks like this

           

           

          Jim

           

          If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

          • 2. Re: Problem with difference calculation for many observations
            Salma Hassan

            Dear Jim Dehner,

            Thank you for your quick reply.

            Here's the workbook attached below.

            But reading your steps, I believe that I've did the same things. But I've came across the problem I've mentioned above.

            Also, one thing I didn't understand about your chart is why there's same values below and above the x axis (0)?

            I mean why there's two of ($10,000) above and below the 0 for example? Sorry for maybe asking an obvious thing, but again, this is all new for me.

            • 3. Re: Problem with difference calculation for many observations
              Jim Dehner

              See the attached

               

              Need some help understanding what the data represents and your goals -

              each record has an age and video id associated with it and a measure value "Total Views"  I would interpret that as the number of views from that video at each age group

               

              if you to determine the "running total' as across the ages there is a different table calculation that does that

               

               

              this is the formula

               

              Now if you want the difference in running total then this is the formula

               

              they would look like this where the lower chart is the difference

               

               

              Tableau has excellent on-line training videos at Tableau Training: View Training Courses

               

              they are broken into short segments that cover specific topics - check them out

               

              Jim

              If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

              • 4. Re: Problem with difference calculation for many observations
                Salma Hassan

                Oh I'm so sorry for the inconvenience, I wasn't clear about what I'm trying to do indeed.

                The Age attribute specifies the video age. So I can see the total views for each video at different video ages.

                For example: when the video age is 1 and total views is 1K, this means that the video gained 1K views in its first day.

                and so on...

                So what I was trying to do is observe the difference in total views each video gains every day.

                And for analysis reasons I want all videos to be plotted in the same chart and each line represent the difference in views from the day previous like on my (figure 1) above but without the strange negative behavior.

                Does this makes any sense now?

                 

                Thanks a lot for your replies and patience.

                 

                **EDIT 1:

                Oh and I'm using the MAX function in Total Views because each video has more than one record in the same day, so I want the max value of views in that day.

                • 5. Re: Problem with difference calculation for many observations
                  Jim Dehner

                  then change Age to your Create date and running-sum(Max(totalviews))

                   

                  we can only respond to what you give us -   see if this works and please go to the training videos

                   

                  Jim

                  If this posts assists in resolving the question, please mark it helpful or as the 'correct answer' if it resolves the question. This will help other users find the same answer/resolution.  Thank you.

                  • 6. Re: Problem with difference calculation for many observations
                    Salma Hassan

                    I think there's some misunderstanding about what I want to do and I'm so sorry for that.

                     

                    Okay, let me ask one simple question.

                    In the worksheet I've attached, there are two sheets, one sheet for all videos and another one for one video only with id: 857103

                    My question is:

                    Why the same video in the sheet (with all videos) have different values than when it showed alone (with negatives values!)?

                    * The correct one is when it's displayed alone.

                     

                    And thank you for the videos they are helpful indeed but I need to understand this issue as quickly as possible.

                    • 7. Re: Problem with difference calculation for many observations
                      Jim Dehner

                      I'm not tracking with you - when I filter the 2 charts for the same video id the plots are the same

                      Maybe someone else can help you

                      Jim

                      • 8. Re: Problem with difference calculation for many observations
                        Salma Hassan

                        Okay. Thanks a lot for your time.

                        I'm clarifying this for anyone else who can help.

                         

                        This is the views difference for some video when its age = 5 (when plotted with other videos)

                        Sketch (2).png

                         

                        And this is the views difference for the same video when its age = 5 also (but when plotted alone)

                         

                        Sketch (1).png

                         

                        As you can see, they are not the same at all!

                        Why is that?

                        Any help would be totally appreciated.