5 Replies Latest reply on Apr 17, 2017 9:34 AM by P N

    How to create calculated field for each date in a date range

    Danjin Sun

      I have multiple devices(each with a unique serial number) in my data source, and each device have multiple active timestamps. I can calculate active date range of each device by allocating the timestamps between the first and last timestamps into days. But since Tableau do not support create data, I cannot create individual dates from that range. However, I do want to see for each date in that range, how many device could have been active (whose first active timestamp <= that date and last active timestamp >= that date), so that I can apply it to the date range and see how potential number of users change along time.


      So basically I want to drag sth like this into Rows and see how it changes along active dates (this code won't work though):


      count = 0

      for serial in .arg4:

          if .arg1 >= .arg2 and .arg1 <= .arg2:

          count += 1

      return count

      ", [Date], [FirstActiveTimestamp], [LastActiveTimestamp], [Serial Numbers])


      I created a toy twb to address the problem, any help would be much appreciated. Thanks!