SOLVED

POWER QUERY - NEW COLUMN

Copper Contributor

Hi

I have to add new column in power query in "Base Usuario".

 

This new column must have this excel related formula:

=COUNT.IFS('Base Integrantes'!AC:AC;"ATIVO";'Base Integrantes'!E:E;[@[Cod_UA]])

 

This column will count a column of another table with 2 criterios as show in excel formula.

 

Could would help me?

4 Replies

@AlessandraMacedo 

As variant, for such sample

image.png

you may add custom column with code like

let
    Source = Excel.CurrentWorkbook(){[Name="BaseUsuario"]}[Content],
    AddCount = Table.AddColumn(
        Source,
        "Count",
        each
            let
                currentField=[UA],
                filterTable=Table.SelectRows(
                    BaseIntegrantes,
                    each (Record.Field(_, "AC") = "ATIVO") and
                         (Record.Field(_, "E") = currentField)
                ),
                countRows = Table.RowCount(filterTable)
            in
                countRows
    )
in
    AddCount
best response confirmed by AlessandraMacedo (Copper Contributor)
Solution

@AlessandraMacedo 

Another variant - make reference on lookup table, filter it on constant (ATIVO), add custom column with value 1

image.png

Merge first table with it on E, expand ID column only

image.png

and group on all columns but ID with SUM aggregation

image.png

Thank you!!! @Sergei Baklan 

@AlessandraMacedo 

You are welcome

1 best response

Accepted Solutions
best response confirmed by AlessandraMacedo (Copper Contributor)
Solution

@AlessandraMacedo 

Another variant - make reference on lookup table, filter it on constant (ATIVO), add custom column with value 1

image.png

Merge first table with it on E, expand ID column only

image.png

and group on all columns but ID with SUM aggregation

image.png

View solution in original post