cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
taubry
Advocate II
Advocate II

GroupBy in dataTable

Good morning !

 

I have a problem with my datatable.

Here are these items:

With(
    {
        groupByFamille: GroupBy(
            Filter(
                Gestion;
                'Exercice budgétaire' = ddBudg_1.Selected.Value || ddBudg_1.Selected.Value=Blank();
                Société = ddSociété_1.Selected.Value || ddSociété_1.Selected.Value=Blank()
            );
            "Famille_x0020_d'achat";
            "Result"
        )

    };
    AddColumns(
        groupByFamille;
        "SumPerFamille";
        Sum(
            Result;
            'Montant HT'
        );
        "DepAuto";
        If(
            Procédure_x0020_applicable = "Demande de devis (Seuil 1)";
            "-";
            Sum(
                Result;
                'Montant HT'
            ) * 0,2
        );
        "DepRea";
        If(Procédure_x0020_utilisée="Petit lot";
        Sum(
                Result;
                'Montant HT'
            )
        )
    )
)

 

I filter at first with 2 selectors. Then I want to add columns. The functions work but power apps does not recognize "Procédure_x0020_utilisée" and "Procédure_x0020_applicable"...

 

it works when i implement them in the GroupBy but it creates too many lines and I just want to create one line per "Family_x200_achat".

 

Ask me questions if my explanation is wrong.

 

Thanks in advance !

 

 

11 REPLIES 11

where should i do the dropcolumn ? 

I'm stuck, all the columns are good but the groupby is bad.

@taubry ,

I assume they will not as you do not want to group by them (therefore they are not in the data you are using with your If() statement) - I was simply using your code value as I cannot see your data.

If you want to use that criteria to add the two columns, you need to do this (you cannot have it both ways - either group by the three columns, or you cannot use that criteria for the additional fields)

With(
   {
      groupByFamille: 
      GroupBy(
         Filter(
            Gestion;
            'Exercice budgétaire' = ddBudg_2.Selected.Value || ddBudg_2.Selected.Value = Blank();
            Société = ddSociété_2.Selected.Value || ddSociété_2.Selected.Value = Blank()
         );
         "Famille_x0020_d'achat";
         Procédure_x0020_applicable;
         Procédure_x0020_applicable;
         "Result"
      )
   };
   AddColumns(
      groupByFamille;
      "SumPerFamille";
      Sum(
         Result;
         'Montant HT'
      );
      "DepAuto";
      If(
         Procédure_x0020_applicable = "Demande de devis (Seuil 1)";
         "-";
         Sum(
            Result;
            'Montant HT'
         ) * 0,2
      );
      "DepRea";
      If(
         Procédure_x0020_utilisée = "Petit lot";
         Sum(
            Result;
            'Montant HT'
         )
      )
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Visit my blog Practical Power Apps

 

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (3,731)