$week_st=($date)-> { 
RETURN DateTime::Format("%Y-%m-%d")(Datetime::MakeDate(DateTime::StartOfWeek(CAST($date as Date))));};

SELECT
    week,
    sum(`Balance`)/7.0 as Balance,
    sum(`Potential`)/7.0 as Potential,
    sum(`Revenue`)/7.0 as Revenue, 
    sum(`Potential`)*1.0/sum(`Balance`) as Potential_share,
    sum(`Revenue`)*1.0/sum(`Potential`) as Revenue_share 
FROM hahn.`home/analyticskeymetrics/export/revenue_potential/v1/daily/total`
WHERE IsTurnedOff IS NULL OR NOT IsTurnedOff
GROUP BY $week_st(`date`) as week;