Skip to main content

Would like to hear anyone’s thoughts on why I cannot get a UI-only formula to display when adding to an aggregate model. 
I have an ungrouped aggregate account model with 3 conditions.
I have 2 aggregations: 1 is the MAX(account_field1)(will call this alias1) and the other is SUM(account_field2) (will call this alias2).
I want to add a UI-only formula to this table that will simply divide one aggregation by the other. 

I am receiving the error message: 
1. Invalid syntax for field formula: alias2/alias1. ReferenceError: alias1 is not defined.

I am confused by the message that this field alias1 is not defined because I have the field added to my table and it is showing up. 

Any help here would be greatly appreciated! 🙂



Lauren,


I would check the formula field. Your alias names in the formula need to use the ‘merge syntax’.


Your formula should look like: {{alias2}}/{{alias1}}


Here is a sample page that uses Opportunities to run the same calculation:


<skuidpage unsavedchangeswarning="" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">
<models>
<model id="OppAgg" limit="" query="true" createrowifnonefound="false" datasource="salesforce" type="aggregate" sobject="Opportunity">
<fields>
<field id="Amount" name="sumAmount" function="SUM"/>
<field id="Amount" name="maxAmount" function="MAX"/>
<field id="PercentMaxDeal" uionly="true" displaytype="FORMULA" label="PercentMaxDeal" ogdisplaytype="TEXT" readonly="true" returntype="PERCENT" precision="9" scale="0">
<formula>{{sumAmount}}/{{maxAmount}}</formula>
</field>
</fields>
<conditions/>
<actions/>
<groupby method="simple"/>
</model>
</models>
<components>
<panelset type="standard" uniqueid="sk-3iyTGX-102" scroll="">
<panels>
<panel width="225px" type="left">
<components>
<template multiple="false" uniqueid="sk-3ixuov-265">
<contents>Max:
{{$Model.OppAgg.data.0.maxAmount}}</contents>
</template>
</components>
</panel>
<panel>
<components/>
</panel>
</panels>
</panelset>
<panelset type="standard" uniqueid="sk-3iyaGo-119" scroll="">
<panels>
<panel type="left" width="225px">
<components>
<template multiple="false" uniqueid="sk-3ixnic-251">
<contents>Sum:
{{$Model.OppAgg.data.0.sumAmount}}</contents>
</template>
</components>
</panel>
<panel>
<components/>
</panel>
</panels>
</panelset>
<panelset type="standard" uniqueid="sk-3iya-f-125" scroll="">
<panels>
<panel type="left" width="225px">
<components>
<template multiple="false" uniqueid="sk-3ixNSM-214">
<contents>Percent:
{{$Model.OppAgg.data.0.PercentMaxDeal}}</contents>
</template>
</components>
</panel>
<panel>
<components/>
</panel>
</panels>
</panelset>
</components>
<resources>
<labels/>
<javascript/>
<css/>
</resources>
<styles>
<styleitem type="background" bgtype="none"/>
</styles>
</skuidpage>

Thanks,


Bill


Thank you Bill for the quick reply! That fixed the issue 🙂
Shot in the dark here…Have you had any luck displaying a UI-percentage formula like that in a chart component (like a donut chart) for %-attainment?