Im trying to calculate a percentage value. Where the dividend is the amount of rows where a timestamp is within a certain range, as well as a column 'customer' is equal to 2. The divisor is the total amount of rows where 'customer' is equal to 2. No timeframe requirement. I tried SAFE_DIVIDE as well as making several measures and calculating the rows in Looker report instead but usually get an error.
Any idea what a solution could be? Is it possible to do in one measure or easier to split into several measures with type:sum, type: percent_1 and so on?
I believe Im using wrong datatypes in below example. Example code:
measure: customer_divided {
type: number
value_format_name: percent_1
view_label: "view_label text"
label: "label text"
description: "descr text"
sql:SAFE_DIVIDE((${Filtered_timeframe_value}),(${TABLE}.customer="2")+;;
}
One possible solution could be to create 2 measures and then use them to create the "customer_divided" measure on the explore view itself.
Once you have created these measures, then you can use them to create the customer_divided measure.