You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: warehouse/models/mart/ntd_validation/fct_ntd_rr20_service_checks.sql
+39-1Lines changed: 39 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -128,7 +128,7 @@ rr20f_179 as (
128
128
rr20f_139 as (
129
129
select
130
130
organization,
131
-
"RR20F-139: Vehicle Revenue Miles change"as name_of_check,
131
+
"RR20F-139: Vehicle Revenue Miles (VRM) % change"as name_of_check,
132
132
mode,
133
133
{{this_year}} as year_of_data,
134
134
CASE WHEN (vrm_{{this_year}} IS NULLOR vrm_{{this_year}} =0 ) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{this_year}}, "-10-31") ASDATE) THEN "Did Not Run"
@@ -287,6 +287,40 @@ rr20f_171 as (
287
287
""as Agency_Response,
288
288
CURRENT_TIMESTAMP() AS date_checked
289
289
from {{ ref('int_ntd_rr20_service_3ratios_wide') }}
290
+
),
291
+
rr20f_143 as (
292
+
select
293
+
organization,
294
+
"RR20F-143: Vehicle Revenue Miles (VRM) change from zero"as name_of_check,
295
+
mode,
296
+
{{this_year}} as year_of_data,
297
+
CASE WHEN (ROUND(vrm_{{this_year}}) =0AND ROUND(vrm_{{last_year}}) !=0AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) > CAST(CONCAT({{this_year}}, "-10-31") ASDATE))
298
+
OR (ROUND(vrm_{{this_year}}) !=0AND ROUND(vrm_{{this_year}}) IS NOT NULLAND ROUND(voms_{{last_year}}) =0)
299
+
THEN "Fail"
300
+
WHEN (vrm_{{this_year}} IS NULLOR vrm_{{this_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{this_year}}, "-10-31") ASDATE)
301
+
THEN "Did Not Run"
302
+
WHEN (vrm_{{last_year}} IS NULLOR vrm_{{last_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{last_year}}, "-10-31") ASDATE)
303
+
THEN "Did Not Run"
304
+
ELSE "Pass"
305
+
END as check_status,
306
+
CONCAT({{this_year}}, " = ", CAST(ROUND(vrm_{{this_year}}) AS STRING),
307
+
", ", {{last_year}}, " = ", CAST(ROUND(vrm_{{last_year}}) AS STRING),
308
+
"chg = ",
309
+
CAST(ROUND((ROUND(vrm_{{this_year}},1) - ROUND(vrm_{{last_year}},1))/ABS(ROUND(vrm_{{this_year}},1)) *100,1) AS STRING),
310
+
"%"
311
+
) as value_checked,
312
+
CASE WHEN (ROUND(vrm_{{this_year}}) =0AND ROUND(vrm_{{last_year}}) !=0AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) > CAST(CONCAT({{this_year}}, "-10-31") ASDATE))
313
+
OR (ROUND(vrm_{{this_year}}) !=0AND ROUND(vrm_{{this_year}}) IS NOT NULLAND ROUND(vrm_{{last_year}}) =0)
314
+
THEN "The Vehicle Revenue Miles (VRM) for this mode has changed either to or from 0 compared to last year, please provide a narrative justification."
315
+
WHEN (vrm_{{this_year}} IS NULLOR vrm_{{this_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{this_year}}, "-10-31") ASDATE)
316
+
THEN CONCAT("No data but this check was run before the NTD submission due date in ",{{this_year}}, " for VOMS.")
317
+
WHEN (vrm_{{last_year}} IS NULLOR vrm_{{last_year}}=0) AND PARSE_DATE('%Y', CAST({{start_date}} AS STRING)) < CAST(CONCAT({{last_year}}, "-10-31") ASDATE)
318
+
THEN CONCAT("No data but this check was run before the NTD submission due date in ",{{last_year}}, " for VOMS.")
319
+
ELSE ""
320
+
END AS description,
321
+
""as Agency_Response,
322
+
CURRENT_TIMESTAMP() AS date_checked
323
+
from {{ ref('int_ntd_rr20_service_3ratios_wide') }}
0 commit comments