{
  "dashboard": {
    "fileType": "parquet",
    "filters": [
      {
        "column": "tpep_pickup_datetime",
        "from": null,
        "sliderMax": null,
        "sliderMin": "2021-01-01",
        "to": null,
        "type": "date",
        "value": null
      },
      {
        "column": "payment_type",
        "labels": "$dimensions(path::/Users/reza/Projects/personal/bucket/yellow-taxi-dimensions/payment_types.csv;;idColumn::id;;nameColumn::name)",
        "numeric": true,
        "type": "multiselect",
        "value": null,
        "values": []
      },
      {
        "column": "RatecodeID",
        "labels": "$labels(1.0::Standard rate;;2.0::JFK;;3.0::Newark;;4.0::Nassau or Westchester;;5.0::Negotiated fare;;6.0::Group ride;;99.0::Null/unknown)",
        "numeric": true,
        "type": "multiselect",
        "value": null,
        "values": []
      },
      {
        "column": "VendorID",
        "labels": "$labels(1::Creative Mobile Technologies, LLC;;2::Curb Mobility, LLC;;6::Myle Technologies Inc;;7::Helix)",
        "numeric": true,
        "type": "multiselect",
        "value": null,
        "values": []
      }
    ],
    "layout": [
      {
        "cells": [
          {
            "chartType": "kpi",
            "flex": 4,
            "name": "Monthly Fare",
            "query": "yellow_taxi_total_fare_by_month"
          },
          {
            "chartType": "kpi",
            "flex": 4,
            "name": "Monthly Trips",
            "query": "yellow_taxi_trips_by_month"
          },
          {
            "chartType": "kpi",
            "flex": 4,
            "name": "Monthly Distance",
            "query": "yellow_taxi_trip_distance_by_month"
          }
        ],
        "height": 250
      },
      {
        "cells": [
          {
            "chartType": "donut",
            "flex": 4,
            "name": "Total Fare by Payment Types",
            "query": "yellow_taxi_total_fare_by_payment_type"
          },
          {
            "chartType": "donut",
            "flex": 4,
            "name": "Total Fare by Rate Code",
            "query": "yellow_taxi_total_fare_by_rateCodeID"
          },
          {
            "chartType": "donut",
            "flex": 4,
            "name": "Total Fare by Vendor",
            "query": "yellow_taxi_total_fare_by_vendorID"
          }
        ],
        "height": 240
      },
      {
        "cells": [
          {
            "chartType": "bubble",
            "flex": 4,
            "name": "Total and Max Fare and Distance by Vendor",
            "query": "yellow_taxi_metrics_by_vendor"
          },
          {
            "chartType": "bar",
            "flex": 4,
            "name": "Total Fare by Fare Range",
            "query": "yellow_taxi_total_fare_by_fare_range"
          },
          {
            "chartType": "line",
            "flex": 4,
            "name": "Total Fare by WeekDay",
            "query": "yellow_taxi_total_fare_by_weekday"
          }
        ],
        "height": 240
      },
      {
        "cells": [
          {
            "chartType": "line",
            "flex": 4,
            "name": "Total Fare by Hour",
            "query": "yellow_taxi_total_fare_by_hour"
          },
          {
            "chartType": "table",
            "flex": 8,
            "name": "Total Fare by Year and Month",
            "query": "yellow_taxi_total_fare_by_year_month"
          }
        ],
        "height": 240
      },
      {
        "cells": [
          {
            "chartType": "paginated",
            "flex": 12,
            "name": "Trip Records",
            "query": "yellow_taxi_trip_records"
          }
        ]
      }
    ],
    "name": "Yellow Taxi",
    "pathToFiles": "/Users/reza/Projects/personal/bucket/yellow-taxi-facts"
  },
  "savedQueries": [
    {
      "name": "yellow_taxi_total_fare_by_payment_type",
      "sql": "-- $dimensions(path::/Users/reza/Projects/personal/bucket/yellow-taxi-dimensions/payment_types.csv;;idColumn::id;;nameColumn::name)\n\nSELECT \n    payment_type,\n    SUM(fare_amount) AS total_fare\nFROM {path-to-files}\nGROUP BY payment_type\norder by 2 desc"
    },
    {
      "name": "yellow_taxi_total_fare_by_vendorID",
      "sql": "-- $labels(1::Creative Mobile Technologies, LLC;;2::Curb Mobility, LLC;;6::Myle Technologies Inc;;7::Helix)\nSELECT \n    VendorID,\n    SUM(fare_amount) AS fare\nFROM {path-to-files}\nGROUP BY VendorID\norder by 2 desc"
    },
    {
      "name": "yellow_taxi_total_fare_by_rateCodeID",
      "sql": "-- $labels(1.0::Standard rate;;2.0::JFK;;3.0::Newark;;4.0::Nassau or Westchester;;5.0::Negotiated fare;;6.0::Group ride;;99.0::Null/unknown)\nSELECT \n    RatecodeID,\n    SUM(fare_amount) AS total_fare\nFROM {path-to-files}\nGROUP BY RatecodeID\norder by 2 desc"
    },
    {
      "name": "yellow_taxi_metrics_by_vendor",
      "sql": "-- $labels(1::Creative Mobile Technologies, LLC;;2::Curb Mobility, LLC;;6::Myle Technologies Inc;;7::Helix)\nSELECT\n      VendorID,\n      SUM(trip_distance) AS total_trip_distance,\n      Max(fare_amount) AS max_fair,\n      SUM(fare_amount) AS total_fair\n  FROM {path-to-files}\n  GROUP BY VendorID"
    },
    {
      "name": "yellow_taxi_total_fare_by_fare_range",
      "sql": "SELECT\n    CASE\n        WHEN fare_amount < 10 THEN '< 10'\n        WHEN fare_amount < 20 THEN '10-20'\n        WHEN fare_amount < 30 THEN '20-30'\n        WHEN fare_amount < 40 THEN '30-40'\n        WHEN fare_amount < 50 THEN '40-50'\n        WHEN fare_amount < 60 THEN '50-60'\n        WHEN fare_amount < 70 THEN '60-70'\n        WHEN fare_amount < 80 THEN '70-80'\n        WHEN fare_amount < 90 THEN '80-90'\n        WHEN fare_amount < 100 THEN '90-100'\n        ELSE '100+'\n    END AS Fare_Range,\n    SUM(fare_amount) AS Total_Fare,\n    SUM(total_amount) AS Total_Amount,\n    Count(*) as Trips\nFROM {path-to-files}\nGROUP BY Fare_Range\nORDER BY MIN(fare_amount);\n\n-- $rangeFilters(< 10::fare_amount < 10;;10-20::fare_amount >= 10 AND fare_amount < 20;;20-30::fare_amount >= 20 AND fare_amount < 30;;30-40::fare_amount >= 30 AND fare_amount < 40;;40-50::fare_amount >= 40 AND fare_amount < 50;;50-60::fare_amount >= 50 AND fare_amount < 60;;60-70::fare_amount >= 60 AND fare_amount < 70;;70-80::fare_amount >= 70 AND fare_amount < 80;;80-90::fare_amount >= 80 AND fare_amount < 90;;90-100::fare_amount >= 90 AND fare_amount < 100;;100+::fare_amount >= 100)"
    },
    {
      "name": "yellow_taxi_total_fare_by_hour",
      "sql": "SELECT \n    Hour(tpep_pickup_datetime),\n    SUM(fare_amount) AS Total_Fare,\n    SUM(total_amount) AS Total_Amount,\n    Count(*) as Trips\nFROM {path-to-files}\nGROUP BY 1\norder by 1;"
    },
    {
      "name": "yellow_taxi_total_fare_by_weekday",
      "sql": "-- $labels(0::Sun;;1::Mon;;2::Tue;;3::Wed;;4::Thu;;5::Fri;;6::Sat)\nSELECT \n    weekday(tpep_pickup_datetime),\n    SUM(fare_amount) AS Total_Fare,\n    SUM(total_amount) AS Total_Amount,\n    Count(*) as Trips\nFROM {path-to-files}\nGROUP BY 1\norder by 1;"
    },
    {
      "name": "yellow_taxi_trip_records",
      "sql": "SELECT *\nFROM {path-to-files}"
    },
    {
      "name": "yellow_taxi_total_fare_by_year_month",
      "sql": "PIVOT (\n    SELECT \n           fare_amount,\n           year(tpep_pickup_datetime)  AS trip_year,\n           month(tpep_pickup_datetime) AS trip_month\n    FROM {path-to-files}\n    WHERE  year(tpep_pickup_datetime) in (2021,2022,2023,2024,2025,2026)\n)\nON trip_month IN (1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)\nUSING format('{:.2f}M', sum(fare_amount) / 1000000.0)\nGROUP BY trip_year\nORDER BY trip_year;"
    },
    {
      "name": "yellow_taxi_total_fare_by_month",
      "sql": "-- $kpi(format::currency)\nSELECT\n    date_trunc('month', tpep_pickup_datetime) AS month,\n    SUM(fare_amount) AS total_fare\nFROM {path-to-files}\nWHERE year(tpep_pickup_datetime) BETWEEN 2021 AND 2026\nGROUP BY 1\nORDER BY 1"
    },
    {
      "name": "yellow_taxi_trips_by_month",
      "sql": "SELECT\n    date_trunc('month', tpep_pickup_datetime) AS month,\n    COUNT(*) AS trips\nFROM {path-to-files}\nWHERE year(tpep_pickup_datetime) BETWEEN 2021 AND 2026\nGROUP BY 1\nORDER BY 1"
    },
    {
      "name": "yellow_taxi_trip_distance_by_month",
      "sql": "SELECT\n    date_trunc('month', tpep_pickup_datetime) AS month,\n    sum(trip_distance) AS trip_distance\nFROM {path-to-files}\nWHERE year(tpep_pickup_datetime) BETWEEN 2021 AND 2026\nGROUP BY 1\nORDER BY 1"
    }
  ]
}