Skip to main content

Notifications

Power Apps - Power Apps Pro Dev & ISV
Answered

ForAll calculation within Collection

(0) ShareShare
ReportReport
Posted on by 68
Hi, 
I have a collection that returns the transaction types based of a available options of a column using the distinct function (this is working).
But when I try to calculate the outstanding count, it returns the same value for all the different transaction types. Any idea what is not working in my formula?
 
ClearCollect(
    TransactionSummary,
    ForAll(
    Distinct(EmployeeTransactions,TransactionType.Value),
    {TransactionType: ThisRecord.Value,
    OutstandingCount: CountIf(
                EmployeeTransactions,
                Status.Value <> "Completed" && TransactionType.Value = ThisRecord.TransactionType.Value
            ),
            ProgressPercentage: RoundUp(
                (CountIf(
                    EmployeeTransactions,
                    Status.Value = "Completed" && TransactionType.Value = ThisRecord.TransactionType.Value
                ) / CountIf(
                    EmployeeTransactions,
                    TransactionType.Value = ThisRecord.TransactionType.Value
                )) * 100,
                0
            )
        }
    )
);

Are is the result I am getting: it returns the total outstanding count in my datasource and applies it to every row.

  • Verified answer
    AndrianaO Profile Picture
    AndrianaO 161 on at
    ForAll calculation within Collection
    Hi, you can try this: 
     
    ClearCollect(
        TransactionSummary,
        ForAll(
        Distinct(EmployeeTransactions,TransactionType.Value) As distinctTransactions,
        {TransactionType: distinctTransactions.Value,
        OutstandingCount: CountIf(
                    EmployeeTransactions,
                    Status.Value <> "Completed" && TransactionType.Value = distinctTransactions.TransactionType.Value
                ),
                ProgressPercentage: RoundUp(
                    (CountIf(
                        EmployeeTransactions,
                        Status.Value = "Completed" && TransactionType.Value = distinctTransactions.TransactionType.Value
                    ) / CountIf(
                        EmployeeTransactions,
                        TransactionType.Value = distinctTransactions.TransactionType.Value
                    )) * 100,
                    0
                )
            }
        )
    );
     
    Let me know if it works! 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November 2024 Newsletter…

November 2024 Community Newsletter…

Community Update Oct 28…

Power Platform Community Update…

Tuesday Tip #9 Get Recognized…

Welcome to a brand new series, Tuesday Tips…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 143,867

#2
RandyHayes Profile Picture

RandyHayes 76,308

#3
Pstork1 Profile Picture

Pstork1 64,174

Leaderboard