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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Creating complex colum...
Power Apps
Unanswered

Creating complex columns (groupBy)

(0) ShareShare
ReportReport
Posted on by 132

Hello,

My problem is quite complex with a large database but I have simplified the thing to explain to you.

 

In the datasource "Gestion" :

Famille d'achatProcédure applicableProcédure utiliséeMontant HT
France1A5
Spain2B1
Germany1A2
Germany1C3
France1A1
Spain2C10
Germany1D10
France1D1
France1B2

 

I wish to have this result in my gallery:

Famille d'achatProcédure applicableExpensesExpenses if A
France196
Spain211-
Germany1151

In column 1, I want to group by "Famille d'achat" (So ​​I used GroupBy).

In column 2, as you can see the "Procédure applicable" is the same for the same "Famille d'achat".

Then in column 3, "Expenses", I want to add all the "Montant HT" of the same family. (sum)

In column 4, the sum of all "Montant HT" if "Procédure utilisée" = A. Otherwise put "-".

 

So, in gallery.item :

With(
 {
 groupByFamille: 
 GroupBy(
 Filter(
 Gestion;
 (
 Len(ddBudg_2.Selected.Value) = 0 ||
 'Exercice budgétaire' = ddBudg_2.Selected.Value)
 && (
 Len(ddSociété_2.Selected.Value) = 0 ||
 Société = ddSociété_2.Selected.Value
 )
 );
 "Famille_x0020_d'achat";
 "Procédure_x0020_applicable";
 "Procédure_x0020_utilisée";
 "Result"
 )
 }; 
 AddColumns(
 groupByFamille;
 "Expenses";
 Sum(
 Result;
 'Montant HT'
 );
 "Expenses if A";
 If(
 Procédure_x0020_utilisée = "A";
 "-";
 Sum(
 Result;
 'Montant HT'
 )
 )
 )
)

Don't worry about the filter.

 

This code works but displays too many rows.

Indeed, I would like to sort only by "Famille_x0020_d'achat"

but if I delete the lines:

"Procédure_x0020_applicable";
"Procédure_x0020_utilisée";

 

This does not work because in "Expenses if A", "Procédure_x0020_utilisée" is not recognized.

and it's impossible to create the column "Procédure applicable" in gallery. 

 

I hope it's easier to understand than the old topic I created.

Hoping someone unlocks me ...

 

Thanks in advance !

 

Categories:
  • WarrenBelz Profile Picture
    156,940 Most Valuable Professional on at

    @taubry ,

    Please do not create another post when we have spent 15 exchanges on this one - or everyone just has to start again without any history.

    I responded a short while ago - also you need to be aware that GroupBy() is a "hidden" Delegation restriction and will only return a result on the first record numbers up to your Delegation limit.

    The problem is that you need to include in the GroupBy() any fields you are using in the If() statements further down, or you cannot test on them.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 243 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 190 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 135

Last 30 days Overall leaderboard