Skip to content

ForAll, GroupBy et AddColumns dans Power Apps Canvas

Dans une application Power Apps Canvas vide, dans OnStart :
ClearCollect(
colVentes;
{ ID: 1; Produit: "Ordinateur portable"; Categorie: "Informatique"; Montant: 1200; Vendeur: "Marie" };
{ ID: 2; Produit: "Souris sans fil"; Categorie: "Informatique"; Montant: 45; Vendeur: "Pierre" };
{ ID: 3; Produit: "Bureau ergonomique"; Categorie: "Mobilier"; Montant: 350; Vendeur: "Marie" };
{ ID: 4; Produit: "Chaise de bureau"; Categorie: "Mobilier"; Montant: 280; Vendeur: "Sophie" };
{ ID: 5; Produit: "Écran 27 pouces"; Categorie: "Informatique"; Montant: 450; Vendeur: "Pierre" };
{ ID: 6; Produit: "Lampe LED"; Categorie: "Mobilier"; Montant: 75; Vendeur: "Sophie" };
{ ID: 7; Produit: "Clavier mécanique"; Categorie: "Informatique"; Montant: 120; Vendeur: "Marie" }
)

GroupBy

ClearCollect(
colVentesParCategorie,
GroupBy(
colVentes; // Une table existante
Categorie; // Une colonne existante de colVentes
Details // Une nouvelle colonne qui contient des tables imbriquées
)
)

AddColumns

ClearCollect(
colAnalyseCategories;
AddColumns(
colVentesParCategorie;
TotalVentes; Sum(Details; Montant);
NombreTransactions; CountRows(Details);
MontantMoyen; Average(Details; Montant)
)
)

ForAll

ClearCollect(
colRapports;
ForAll(
colAnalyseCategories;
{
Categorie: ThisRecord.Categorie;
Rapport: "La catégorie " & ThisRecord.Categorie & " a généré " & ThisRecord.TotalVentes & " € sur " & ThisRecord.NombreTransactions & " ventes.";
Performance: If(ThisRecord.TotalVentes > 1000; "Excellente"; "À améliorer");
DateRapport: Today()
}
)
)
Want to print your doc?
This is not the way.
Try clicking the ··· in the right corner or using a keyboard shortcut (
CtrlP
) instead.