Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combine PowerBI DAX Filter and SELECTCOLUMN

I want to create a new table based on this one: This is my initial table

that filters for Warehouse=2 and "drops" the columns "Price" and "Cost" like this:

This is what I want to have

I have managed to apply the filter in the first step using:

FILTER(oldtable;oldtable[Warehouse]=2)

and then in the next step cold create another table that only selects the required columns using:

newtable2=SELECTCOLUMNS("newtable1";"Articlename";...)

But I want to be able to combine these two functions and create the table straight away.

like image 252
Lorenz Joe Avatar asked Jul 17 '19 22:07

Lorenz Joe


1 Answers

This is very simple, because in your first step, a table is returned which you can use directly in your second statement.

newTabel = SELECTCOLUMNS(FILTER(warehouse;warehouse[Warehouse]=2);"ArticleName";warehouse[Articlename];"AmountSold";warehouse[AmountSold];"WareHouse";warehouse[Warehouse])

If you want to keep the overview, you can also use variables and return:

    newTabel = 
        var filteredTable = FILTER(warehouse;warehouse[Warehouse]=2)
        return SELECTCOLUMNS(filteredTable;"ArticleName";warehouse[Articlename];"AmountSold";warehouse[AmountSold];"WareHouse";warehouse[Warehouse])
like image 198
Aldert Avatar answered Sep 23 '22 12:09

Aldert