table count duplicates

  • 1
  • Question
  • Updated 5 days ago
  • Answered
I have a table and have column that I would like to identify duplicate numbers.  In excel I can use an "if" statement to compare the 2 fields in adjacent rows.  Is there a method to do that in Skuid table?
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb

Posted 5 days ago

  • 1
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
https://docs.skuid.com/latest/en/skui...

You can add a UI only formula field to your model with conditional logic as explained in the above link.
Photo of Bill Fox

Bill Fox

  • 7,954 Points 5k badge 2x thumb
Hello Raymond,

 Can you point out the section that compares data from two different rows.  I see data from the same row, but not different rows.
Photo of Skuidward Tentacles (Raymond)

Skuidward Tentacles (Raymond), Champion

  • 17,224 Points 10k badge 2x thumb
I must have missed your question(even though now When I read it it seems pretty clear).....
the only practical way I can think to do this without JavaScript would be to create a second model, then ad a row action that sets a condition a condition on the second model so that it only returns rows that have a value equal to the value in the field you are trying to find duplicates on. Then have a table display the rows from the second model in a popup.
Photo of Bill McCullough

Bill McCullough, Champion

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

This is a variation on something that Zach McElrath posted.  Skuid generates an 'index' merge variable on a table.  You can use this with some formula fields to look one row ahead (or behind) for comparisons.  Use the Model Lookup function along with the IndexPlus (index +1) field to look one row ahead and retrieve the same value.

Here are the key formula fields:

Index
{{index}}

IndexPlus
{{index}}+1

MoreThanNextRow
IF({{Amount}}>MODEL_LOOKUP("Opportunity","Amount","Index",{{IndexPlus}}),'Yes','No')

Here is a sample page based on Opportunity that you can try to see it in action:

<skuidpage unsavedchangeswarning="yes" personalizationmode="server" useviewportmeta="true" showsidebar="false" showheader="false" tabtooverride="Opportunity">
    <models>
        <model id="Opportunity" limit="100" query="true" createrowifnonefound="false" datasource="salesforce" sobject="Opportunity">
            <fields>
                <field id="Name"/>
                <field id="CreatedDate"/>
                <field id="StageName"/>
                <field id="Amount"/>
                <field id="CloseDate"/>
                <field id="MoreThanNextRow" uionly="true" displaytype="FORMULA" label="MoreThanNextRow" ogdisplaytype="TEXT" readonly="true" returntype="TEXT">
                    <formula>IF({{Amount}}&gt;MODEL_LOOKUP("Opportunity","Amount","Index",{{IndexPlus}}),'Yes','No')</formula>
                </field>
                <field id="Index" uionly="true" displaytype="FORMULA" label="Index" ogdisplaytype="TEXT" readonly="true" returntype="DOUBLE" precision="9" scale="0">
                    <formula>{{index}}</formula>
                </field>
                <field id="IndexPlus" uionly="true" displaytype="FORMULA" label="IndexPlus" ogdisplaytype="TEXT" readonly="true" returntype="DOUBLE" precision="9" scale="0">
                    <formula>{{Index}}+1</formula>
                </field>
            </fields>
            <conditions/>
            <actions>
                <action>
                    <actions>
                        <action type="custom" snippet="newSnippet"/>
                    </actions>
                    <events>
                        <event>models.loaded</event>
                    </events>
                </action>
            </actions>
        </model>
    </models>
    <components>
        <pagetitle model="Opportunity" uniqueid="sk-3x6o-e-199">
            <maintitle>
                <template>{{Model.labelPlural}}</template>
            </maintitle>
            <subtitle>
                <template>Home</template>
            </subtitle>
            <actions>
                <action type="savecancel" uniqueid="sk-3x6o-d-197"/>
            </actions>
        </pagetitle>
        <skootable showconditions="true" showsavecancel="false" searchmethod="server" searchbox="true" showexportbuttons="false" pagesize="10" createrecords="true" model="Opportunity" mode="read" allowcolumnreordering="true" uniqueid="sk-3x6o-y-213">
            <fields>
                <field id="Name" hideable="true" allowordering="true" uniqueid="fi-3x6nIq-914">
                    <renderconditions logictype="and" onhidedatabehavior="keep"/>
                    <enableconditions/>
                </field>
                <field id="CloseDate" hideable="true" uniqueid="fi-2t8z-402" allowordering="true"/>
                <field id="StageName" hideable="true" uniqueid="fi-3x6rFe-255">
                    <renderconditions logictype="and" onhidedatabehavior="keep"/>
                    <enableconditions logictype="and"/>
                </field>
                <field id="Amount" hideable="true" uniqueid="fi-3xbN-394"/>
                <field id="MoreThanNextRow" hideable="true" uniqueid="fi-3xXO-589"/>
                <field id="Index" hideable="true" uniqueid="fi-3xXd-728"/>
                <field id="IndexPlus" hideable="true" uniqueid="fi-3xYi-988"/>
            </fields>
            <rowactions>
                <action type="edit"/>
                <action type="delete"/>
            </rowactions>
            <massactions usefirstitemasdefault="true">
                <action type="massupdate"/>
                <action type="massdelete"/>
            </massactions>
            <views>
                <view type="standard"/>
            </views>
        </skootable>
    </components>
    <resources>
        <labels/>
        <css/>
        <javascript/>
        <actionsequences uniqueid="sk-3x6rFZ-252"/>
    </resources>
    <styles>
        <styleitem type="background" bgtype="none"/>
    </styles>
</skuidpage>

Thanks,

Bill