cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Joan_Zulo
Regular Visitor

Sum a column from a datatable

Hi, I have a data table that is connected to SP list "Cartera1", these data table is filtered by an ID based on a TextInput the user enter, I need to sum the column "saldocapital" from that table and show it in a label, I have tried the next formula but a delegation warning is showed and it is not showing the sum:

 

Formula used to filter the datatable (These filter is working fine):

Filter(Cartera1;StartsWith(cedulasociado;TextInput2.Text))

 

Formula used to sum the column "saldocapital"

"Saldo Total: " & Text(Sum(Filter(Cartera1;TextInput2.Text);saldocapital);"[$-en-US]$#,###.00")

 

 The result:

DelegationWarning.PNG

 

 

How could I try to get this sum done and how to give currency format to the column in the data table and the label?

 

Thanks in advance,

1 ACCEPTED SOLUTION

Accepted Solutions
StalinPonnusamy
Super User
Super User

Hi @Joan_Zulo 

 

 

 

With(
    {
        _item: Filter(
            Cartera1;
            StartsWith(
                cedulasociado;
                TextInput2.Text
            )
        )
    },
    Text(Sum(
        _item;
        saldocapital
    );"[$-en-US]$#,###.00")
)

 

 

Or (Another Method)

With(
    {wCode: Cartera1};
    Text(Sum(
        Filter(
            wCode;
            StartsWith(
                cedulasociado;
                TextInput2.Text
            )
        );
        saldocapital
    );"[$-en-US]$#,###.00")
)

 

Reference:

StalinPonnusamy_0-1630984641719.png

 

View solution in original post

11 REPLIES 11
StalinPonnusamy
Super User
Super User

Hi @Joan_Zulo 

 

The sum is not delegable. Please try the below formula

With({_items: Filter(Cartera1, condition)};
    Text(Sum(_items; saldocapital);"[$-en-US]$#,###.00")
)

 

StalinPonnusamy
Super User
Super User

Hi @Joan_Zulo 

 

 

 

With(
    {
        _item: Filter(
            Cartera1;
            StartsWith(
                cedulasociado;
                TextInput2.Text
            )
        )
    },
    Text(Sum(
        _item;
        saldocapital
    );"[$-en-US]$#,###.00")
)

 

 

Or (Another Method)

With(
    {wCode: Cartera1};
    Text(Sum(
        Filter(
            wCode;
            StartsWith(
                cedulasociado;
                TextInput2.Text
            )
        );
        saldocapital
    );"[$-en-US]$#,###.00")
)

 

Reference:

StalinPonnusamy_0-1630984641719.png

 

ShrikantKore
Frequent Visitor

You can simply use this formula

 

Sum(Filter(<same filter as data table>),Column_Name)

hey you can refer  this image for your solution

AmolPomaji05
Frequent Visitor

Hello @Joan_Zulo 

you can use the sum function. i.e :- Sum(Gallery14.AllItems,ColumnName);

you will get the sum of that particular column from the Database.

Thanks @StalinPonnusamy I tried the first method you proposed and it worked properly.

Thanks @StalinPonnusamy  What if I need to compute this sum with some conditions, I mean, there's a column named "categoriafinal" it contains letters (A-B-C-D-E) and I need the sum only when this column is different from A?

 

How could I include this condition in the first method you proposed?

 

Thanks,

StalinPonnusamy
Super User
Super User

Hi @Joan_Zulo 

 

Please try this

 

With(
    {
        _item: Filter(
            Cartera1;
            StartsWith(
                cedulasociado;
                TextInput2.Text
            )
        )
    },
    Text(Sum(
        Filter(_item; "A-B-C-D-E" in 'categoriafinal');
        saldocapital
    );"[$-en-US]$#,###.00")
)

@StalinPonnusamy I adjusted the code below with the operator "OR", for some reason is not computing the sum when is "B", the other letters are computing the sum correctly.

With(
    { _item: Filter(
        Cartera1;
        StartsWith(
            cedulasociado;
            TextInput2.Text
        )
    )
    };
    Text(Sum(
        Filter(_item; "B" || "C" || "D" || "E" in categoriafinal);
                saldocapital
    );"[$-en-US]$#,###.00")
)

 

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power Platform Call June 2022 768x460.png

Power Platform Community Call

Join us for the next call on June 15, 2022 at 8am PDT.

PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PA.JPG

New Release Planning Portal (Preview)

Check out our new release planning portal, an interactive way to plan and prepare for upcoming features in Power Platform.

Top Solution Authors
Top Kudoed Authors
Users online (2,319)