cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pamboys09
Helper I
Helper I

Sumifs and Sort Powerapps

Hello,

 

I've been testing powerapps and I got stuck on trying to summarize the report to a gallery.

So i have this data on sharepoint list. (*dummy data)

 

ItemTotal AmountTargetMultiplier
A50510
A60510
A70510
A8057
B5068
B5068

 

I want to show on my gallery group by item and amount % sort by the highest on top

 

Amount % = Total Amount / (Target * Multiplier)

 

Here's the expected result in Gallery

 

B52%
A35%

 

I manage to put the Item by grouping them(groupby), but i got stuck on sorting them descending.

 

Appreciate any help.

 

Thanks

Chris

 

1 ACCEPTED SOLUTION

Accepted Solutions

@pamboys09 
Like this...

 

// your data
ClearCollect(colDummyData,
{Item:"A",'Total Amount':50,Target: 5,Multiplier: 10},
{Item:"A",'Total Amount':60,Target: 5,Multiplier: 10},
{Item:"A",'Total Amount':70,Target: 5,Multiplier: 10},
{Item:"A",'Total Amount':80,Target: 5,Multiplier: 7},
{Item:"B",'Total Amount':50,Target: 6,Multiplier: 8},
{Item:"B",'Total Amount':50,Target: 6,Multiplier: 8}
);

// calculate percentage for each item and group
ClearCollect(
    myUngroupedSolution,
    DropColumns(
        AddColumns(
            GroupBy(AddColumns(colDummyData, "Amount %", 'Total Amount' / (Target * Multiplier)),"Item","GroupedItems"),
        "Sum of Value",Sum(GroupedItems,'Amount %')
        ),
    "GroupedItems"
    )
);

// find the proportion of the whole and sort
ClearCollect(
    myGroupedSolution,
    ShowColumns(
        Sort(
            AddColumns(
                myUngroupedSolution,
                "Percentage",
                Text('Sum of Value'/Sum(myUngroupedSolution,'Sum of Value')*100,"[$-en-US]0.0%")
            ),Percentage, Descending),
    "Item","Percentage")
);

 


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

2 REPLIES 2
mdevaney
Super User III
Super User III

...

@pamboys09 
Like this...

 

// your data
ClearCollect(colDummyData,
{Item:"A",'Total Amount':50,Target: 5,Multiplier: 10},
{Item:"A",'Total Amount':60,Target: 5,Multiplier: 10},
{Item:"A",'Total Amount':70,Target: 5,Multiplier: 10},
{Item:"A",'Total Amount':80,Target: 5,Multiplier: 7},
{Item:"B",'Total Amount':50,Target: 6,Multiplier: 8},
{Item:"B",'Total Amount':50,Target: 6,Multiplier: 8}
);

// calculate percentage for each item and group
ClearCollect(
    myUngroupedSolution,
    DropColumns(
        AddColumns(
            GroupBy(AddColumns(colDummyData, "Amount %", 'Total Amount' / (Target * Multiplier)),"Item","GroupedItems"),
        "Sum of Value",Sum(GroupedItems,'Amount %')
        ),
    "GroupedItems"
    )
);

// find the proportion of the whole and sort
ClearCollect(
    myGroupedSolution,
    ShowColumns(
        Sort(
            AddColumns(
                myUngroupedSolution,
                "Percentage",
                Text('Sum of Value'/Sum(myUngroupedSolution,'Sum of Value')*100,"[$-en-US]0.0%")
            ),Percentage, Descending),
    "Item","Percentage")
);

 


---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

View solution in original post

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (26,156)