Today, consisted mainly of creating my tables in SQL, validating my data and sketching out my dashboards. By the end of the day, I was able to create one KPI but there are still some ways to go before I have two finished dashboards!
As I was creating my tables in Snowflake, I wanted to make sure that I validated my data the entire way and added the necessary constraints to reduce the amount of nulls and ensure my data quality is pristine.
Workflow
The first part of my day consisted of creating all my dimension tables because in my schema there were a few unique IDs that I had to create (e.g. house_id) which required window functions, string parsing and CTEs. One of the first issues arose when I was creating my Buildings_Dim table because this is the one table that referenced the geo_id I created yesterday from the American Community Survey Data. Essentially, this is the table that bridges my two datasets together so it was critical that the keys matched. As I was developing my script to create the GEOID (ex. 36081115700) in my Buildings_Dim, I was comparing tract numbers between the NYC Open Data data set and ACS and found out that NYC Open Data abbreviates tract numbers where as in the US Census tract numbers are always at least three digits. For example:
- American Community Survey Dataset: tract "65" = "65.00" (but with the decimal removed "6500"
- NYC Open Data Dataset: tract "65" = "65"
Thus, I needed to rectify by padding the values in the Housing_Violations dataset where tract numbers with a length greater to or equal than 4 digits are left padded with one zero at the beginning and one at the end. And, anything less is padded with two zeroes at the end to match the conventions of US Census Bureau tract numbers. The script came out to the following:
select distinct
h."BuildingID"::int,
h."StreetCode"::int,
h."Longitude"::float,
h."Latitude"::float,
h."CouncilDistrict"::int,
'36' || b.boro_code ||
case
when length(h."CensusTract") >= 4 then lpad(h."CensusTract", 6, '0')
else lpad(h."CensusTract", 4, '0') || '00'
end as geoid
from "JC_NYC_Housing_Code_Violations_Raw" as h
join borough_codes as b on b."BoroID" = h."BoroID"Where the b.boro_code values come from a CTE I wrote right before mapping the borough_ids from the Housing Violations Table (NYC Open Data) to the county numbers from the American Community Survey Dataset (US Census Bureau).
After creating all of my dimension tables, I created my fact table last because there ae several foreign keys in my violations_fact table that reference keys in my dimension tables. However, in contrast to the last time I did this exercise, one piece of feedback I received was to ensure I have a single source of truth for all the IDs I create. So this time, I stored all unique IDs that I created for my dimension tables in CTEs that I would, later, join on to my fact table.
Sketching
One of the most important steps when creating a dashboard in sketching, this was a step I took when creating my application dashboard and still do it to this day! The requirements for this project is that we two dashboards. One overview dashboard that an executive will only have a minute or so to look at and an analyst dashboard that can give users row level detail (it should also include interactivity!). In Excalidraw, I developed the following sketches:


Next Steps
- Build out dashboards in Tableau
- Document!

