Summarize opportunity by product

  • 1
  • Question
  • Updated 2 years ago
  • Answered
I want to replicate a SF chart in Skuid.  Simply a column chart with the sum of opportunities split by product.  Data axes = Amount; category axes = Product Name.  How do I get product name as a category field?
Photo of Tyler Fisher

Tyler Fisher

  • 358 Points 250 badge 2x thumb

Posted 2 years ago

  • 1
Photo of Bill McCullough

Bill McCullough, Champion

  • 12,436 Points 10k badge 2x thumb
Tyler,

I did this using an Aggregate model on Opportunity Line Items.  I sum on Opportunity.Amount and Group By Product.Name.  Is this what you are after?

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" showsidebar="true" useviewportmeta="true" showheader="true">    <models>
        <model id="OppByProduct" limit="" query="true" createrowifnonefound="false" datasource="salesforce" type="aggregate" sobject="OpportunityLineItem">
            <fields>
                <field id="Opportunity.Amount" name="sumOpportunityAmount" function="SUM"/>
            </fields>
            <conditions/>
            <actions/>
            <groupby method="simple">
                <field id="Product2Id" name="product2Id"/>
                <field id="Product2.Name" name="product2Name"/>
            </groupby>
        </model>
    </models>
    <components>
        <skuidvis__chart model="OppByProduct" maintitle="{{Model.labelPlural}}" type="column" uniqueid="sk-PQVRj-123">
            <dataaxes>
                <axis id="axis1"/>
            </dataaxes>
            <categoryaxes>
                <axis id="categories" categorytype="field" field="product2Name"/>
            </categoryaxes>
            <serieslist>
                <series valuefield="sumOpportunityAmount" splittype="none"/>
            </serieslist>
            <colors/>
            <legend layout="horizontal" halign="center" valign="bottom"/>
        </skuidvis__chart>
    </components>
    <resources>
        <labels/>
        <javascript/>
        <css/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>
Thanks,

Bill
Photo of Tyler Fisher

Tyler Fisher

  • 358 Points 250 badge 2x thumb
Thanks Bill, that is what I needed.  Although, I have an oppty chart that responds to table filters for Owner, Close Date, stage and it is also filterable on product.name through a opptylineitem subquery condition on the oppty model.  Ideally, I would like to have that chart with product.name as a category.  For now I'll move forward with two visualisations. 
Photo of Tyler Fisher

Tyler Fisher

  • 358 Points 250 badge 2x thumb
Got into building my chart and your solution, Bill, will deliver everything I need, AWESOME!!