Timeseries Value Lookup and difference in Quicksight

0

If we are storing timestamped data of sensors and values in DynamoDB or Timestream as

  • t1,odometer, 120
  • t2,odometer, 122
  • t3,odometer, 123

and so on, and would like to find out how many miles the car has driven in the last 30 days for a year, how can I do that in Quicksight/Athena and plot them in the bar graph for every month in the year?

Total miles travelled = Value(t2) - Value(t1)

Is there a way to lookup the value at a given time and take that and subtract that will value at the current time function?

jinman
asked 2 years ago1218 views
2 Answers
1
Accepted Answer
  1. Create a dataset to connect your Data Source I used a simple excel spreadsheet with 3 columns "date","metric","value"

Be sure to configure the 'date' column so it correctly parses your data source date formats The help on "Preparing Datasets" has advice on this Make sure the "date" column is of "Date" type (it looks like a calendar icon)

  1. Create an Analysis from your dataset
  2. Create a calculated field (in either the analysis or the dataset)
    For analysis click "Add" , "Add calculated field" The calculated field should produce "miles driven" since the previous record. I used the following formula

max(value) - lag(max(value),[date ASC],1)

The documentation for calculated fields has many examples of this. The above produces the difference between the maximum of the current time period's miles minus the maximum of the previous time periods miles.

I called my field "driven"

  1. Add (or reuse the default) visual.
    Select the chart wanted (I clicked on a column chart)
  2. Drag "date" and "driven" onto the visual
  3. Using the Field Well, select "date" and change the agragation to whatever period you want, I chose "By Month"

The result is a column graph of miles driven per month

DALDEI
answered 2 years ago
  • Hi @daldei,

    Thank you for the amazing and fantastic description. It really helped us.

    One question though: Is there any way we can get the difference of particular time in the past (like 30 days)? Is there any quick way to basically get the value 30 days ago that we can assign as calculated field?

    Again, thank you for your help!

  • Unfortunately, this solution does not help us for lag of 30 day. Any idea how we can do it? @daldei. Should we use https://docs.aws.amazon.com/quicksight/latest/user/periodToDateAvg-function.html

0
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions