Beastmode syntax for the following condition help

I am trying to do calculate a rate called Coverage Rate

 

Columns are Coverage and Dollar Amount

Values in Coverage column are either "Covered" or "Not Covered".

I want to know the total dollars for WHERE Coverage = Covered

that is easy, but if i wan to devide those total dollars where coverage = covered  by total dollars, how do i write that. 

= (SUM(`Dollars`) where `Coverage` = "Covered")  / sum(`Dollars`)

 

Comments

  • Tomo
    Tomo Contributor

    Hi @user07805

     

    BEAST MODE

     

    sum(
    case
    when `Coverage` = 'Covered' then `Dollars`
    else 0
    end
    )
    /
    nullif(sum(`Dollars`) ,0)