Can you add, edit, or update table calculations in Looks via the API?

Yes, you can update the query object associated with a Look. There's a property called dynamic_fields which you can use to add, update, or remove table calculations.

To get the logic for the table calcs, you can build a query with table calcs, open up Dev Tools, look at how Looker constructs the query in the Network tab and copy the logic into your API call.

The logic for this table calc:

if(${orders.count_pending}>500,"deficit","surplus")

is displayed in the Network tab as:

dynamic_fields: "[{"table_calculation":"table_calc_logic","label":"Table_calc_logic","expression":"if(${orders.count_pending}>500,\"deficit\",\"surplus\")","value_format":null,"value_format_name":null,"_kind_hint":"measure","_type_hint":"string"}]"

Expand query in the Network tab to get the full logic:

c04e0a03-4259-4664-acf2-06928c0c5e31.png

This content is subject to limited support.                

Version history
Last update:
‎07-14-2021 09:26 AM
Updated by: