Forum Discussion
Conditional sum in nested table
- 2 years ago
Hi AriB
Table.AggregateTableColumn acts on only a single column within the nested table, so it can't apply a filter to any columns other than the one being aggregated.
Instead, try this, which filters the nested table with Table.TransformColumns before applying Table.AggregateTableColumn.
#"Création colonne quotité" = Table.DuplicateColumn( #"Calcul du nombre d'affectations", "Agent", "Qtité Occ." ), #"Calcul de la quotité" = Table.AggregateTableColumn( Table.TransformColumns( #"Création colonne quotité", {"Qtité Occ.", each Table.SelectRows(_, each [Affecté] = 1)} ), "Qtité Occ.", {{"Qté Occ.", List.Sum, "Qté Occ."}} )You could also write it this way with a separate step "Filter nested table" applying Table.TransformColumns:
#"Création colonne quotité" = Table.DuplicateColumn( #"Calcul du nombre d'affectations", "Agent", "Qtité Occ." ), #"Filter nested table" = Table.TransformColumns( #"Création colonne quotité", {"Qtité Occ.", each Table.SelectRows(_, each [Affecté] = 1)} ), #"Calcul de la quotité" = Table.AggregateTableColumn( #"Filter nested table", "Qtité Occ.", {{"Qté Occ.", List.Sum, "Qté Occ."}} )Do these work for you?
Regards
Hi AriB
Table.AggregateTableColumn acts on only a single column within the nested table, so it can't apply a filter to any columns other than the one being aggregated.
Instead, try this, which filters the nested table with Table.TransformColumns before applying Table.AggregateTableColumn.
#"Création colonne quotité" = Table.DuplicateColumn(
#"Calcul du nombre d'affectations",
"Agent",
"Qtité Occ."
),
#"Calcul de la quotité" = Table.AggregateTableColumn(
Table.TransformColumns(
#"Création colonne quotité",
{"Qtité Occ.", each Table.SelectRows(_, each [Affecté] = 1)}
),
"Qtité Occ.",
{{"Qté Occ.", List.Sum, "Qté Occ."}}
)
You could also write it this way with a separate step "Filter nested table" applying Table.TransformColumns:
#"Création colonne quotité" = Table.DuplicateColumn(
#"Calcul du nombre d'affectations",
"Agent",
"Qtité Occ."
),
#"Filter nested table" = Table.TransformColumns(
#"Création colonne quotité",
{"Qtité Occ.", each Table.SelectRows(_, each [Affecté] = 1)}
),
#"Calcul de la quotité" = Table.AggregateTableColumn(
#"Filter nested table",
"Qtité Occ.",
{{"Qté Occ.", List.Sum, "Qté Occ."}}
)
Do these work for you?
Regards