web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Convert rows to column...
Power Apps
Unanswered

Convert rows to columns in Power Apps

(0) ShareShare
ReportReport
Posted on by 181
Hi Power Apps Community,
 
I have an app fetching data from data verse table and would like to convert rows to columns and find the sum of quantity. 
 
Input Table
 
Expected output
 
 
tried achieving the expected result using group by. Could someone help accomplish above. Thanks 
 
SV 
Categories:
I have the same question (0)
  • Suggested answer
    Pacel1 Profile Picture
    79 on at
    I was tested this on my site, and below You have a working solution :)
     
    ClearCollect(
        tempCollection,                //Name of temp collection
        AddColumns(
            GroupBy(
                YourDataSet, //Reference to Your Collection 
                Client,         // First group Column
                Distributor,    //Second group Column
                Month,          //Third group Column
                Groupeddata     //Column with grouped data -- 
            ),
            SUM,                //Name of newly added column where Your summed data will present
            Sum(
                ThisRecord.Groupeddata,
                Quantity
            )
        )
    )
     
  • ronaldwalcott Profile Picture
    3,847 Super User 2025 Season 2 on at
    Do you just want to display the output or are you using the data for some other function as you could do this using Power BI? 
  • Suggested answer
    Daniel Bocklandt Profile Picture
    5,099 Super User 2025 Season 2 on at
     
    I have managed to do it like this (colTest is the Input Table): 
    ClearCollect(
        colInterm,
        AddColumns(
            colTest,
            ClientDistributor,
            Client & Distributor
        )
    );
    Clear(colResults);
    ClearCollect(
        colDistinct,
        Distinct(
            colInterm,
            ClientDistributor
        )
    );
    ForAll(
        colDistinct As X,
        With(
            {
                ClientValue: LookUp(
                    colInterm,
                    ClientDistributor = X.Value
                )
            },
            Collect(
                colResults,
                {
                    Client: ClientValue.Client,
                    Distributor: ClientValue.Distributor,
                    Month: ClientValue.Month,
                    Quantity: Sum(
                        Filter(
                            colInterm,
                            ClientDistributor = X.Value
                        ),
                        Quantity
                    )
                }
            )
        )
    )
    I don't know if it's the fastest way. Since this was my first attempt probably not but let me know it this works for you 

    If this solvede your porblem please accept it as solution so others can find it as well. 
    If it helped in any other way consider liking it so we can keep supporting eachother. 
  • CU20081036-0 Profile Picture
    181 on at
    @Pacel1,
     
    Thanks for the response. It works. How to convert column month to row like shown below. Thanks
     
  • Verified answer
    Pacel1 Profile Picture
    79 on at
    Hi, You should try something simmilar to previous solution. 
     
    ClearCollect(
        testowa1,                //Name of temp collection
        AddColumns(
            GroupBy(
                TempCollection1, //Reference to Your Collection 
                Client,         // First group Column
                Distributor,    //Second group Column
                Groupeddata     //Column with grouped data -- 
            ),
            JAN,                //Name of newly added column where Your summed data will present
            Sum(Filter(ThisRecord.Groupeddata, Month = "Jan"),
                Quantity
            ),
            FEB,                //Name of newly added column where Your summed data will present
            Sum(Filter(ThisRecord.Groupeddata, Month = "Feb"),
                Quantity
            ),
            MAR,                //Name of newly added column where Your summed data will present
            Sum(Filter(ThisRecord.Groupeddata, Month = "Mar"),
                Quantity
            )
        )
    )

    If this solved your porblem please accept it as solution :)
  • CU20081036-0 Profile Picture
    181 on at
    @Pacel1,
     
    I have run into an issue recently. Data that I'm after is present till AddColumns step, however, collecting it into collection fails with few records missing.
     
    Any suggestions on the troubleshooting would be helpful. Thanks

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 840 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 332 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 275

Last 30 days Overall leaderboard