Loopings in Look ML Code

I am trying to use loops in LookML Code. is that possible?

I have to take data from one view and place the data from a view into one variable in the current view. Depending upon the number of rows in the current view, We use the same variables as loop.

Please find the code below: Let me know, If I am making any wrongs:

{% capture distinct_dates_filenm %} {{ epc_dsis.distinct_dates._value }} {% endcapture %}
{% for file_dt in distinct_dates %}

SELECT ‘EPC_ATHENA_STAGING’ AS SOURCE, {{file_dt}} AS CURRENT_FILE_DT,
CASE
WHEN
(SELECT COUNT(WORKFLOW_INSTANCE_ID) FROM VW_WORKFLOW_EXECUTION_STATUS where WORKFLOW_NAME=‘Hive Stage STG_ESPN_EPC_ATHENA’ AND file_nm like CONCAT(’%’,CAST({{file_dt}} AS VARCHAR(10)),’%’)) >0
THEN
(SELECT TOP 1 WORKFLOW_INSTANCE_STATUS from VW_WORKFLOW_EXECUTION_STATUS where WORKFLOW_NAME=‘Hive Stage STG_ESPN_EPC_ATHENA’ AND file_nm like CONCAT(’%’,CAST({{file_dt}} AS VARCHAR(10)),’%’)) ORDER BY WORKFLOW_INSTANCE_ID DESC)
ELSE
(SELECT ‘LOAD NOT STARTED’)
END AS LOAD_STATUS,
(SELECT TOP 1 A.LAST_LOAD_DATE FROM (SELECT CAST(format(cast(START_DT as date),‘yyyy-MM-dd’) AS VARCHAR(10)) AS LAST_LOAD_DATE FROM VW_WORKFLOW_EXECUTION_STATUS WHERE WORKFLOW_NAME IN (‘Hive Stage STG_ESPN_EPC_ATHENA’) AND WORKFLOW_INSTANCE_STATUS LIKE ‘%COMPLETE%’) A
JOIN (SELECT CAST(format(cast(START_DT as date),‘yyyy-MM-dd’) AS VARCHAR(10)) AS LAST_LOAD_DATE FROM VW_WORKFLOW_EXECUTION_STATUS WHERE WORKFLOW_NAME IN (‘HIVE Staging STG_ESPN_EPC_ATHENA >> HIVE MART Table for mastering data F_PREFERENCE_EPC’) AND WORKFLOW_INSTANCE_STATUS LIKE ‘%COMPLETE%’)B ON A.LAST_LOAD_DATE=B.LAST_LOAD_DATE ORDER BY A.LAST_LOAD_DATE DESC)
AS LAST_LOAD_DATE,
‘Through previous day’ AS Expected_Load_through_date;;
}

dimension: source {
type: string
sql: ${TABLE}.SOURCE ;;
}

dimension: current_file_dt {
type: string
sql: ${TABLE}.CURRENT_FILE_DT ;;
}

dimension: load_status {
type: string
sql: ${TABLE}.LOAD_STATUS ;;
}

dimension: last_load_date {
type: string
sql: ${TABLE}.LAST_LOAD_DATE ;;
}

dimension: expected_load_through_date {
type: string
sql: ${TABLE}.Expected_Load_through_date ;;
}