Search code examples
daxpowerbi-desktopnew-operator

How can I create a new table in Power BI from three columns of another two table with a filter?


I have used below DAX & result is ok but pls help me to get same data from two tables

  1. SALES
  2. RETURNS

both tables have same 3 columns.. & I want to take this data in new table..

Pls help me to get this from two tables into one


How to select N columns from a PowerBI table?

answered Oct 6, 2020 at 14:33 Alexis Olson

The SELECTCOLUMNS function allows you to pick specific columns.

For example:

New Filtered Table =
Customers = DISTINCT(
    SELECTCOLUMNS (
        CALCULATETABLE (
            SALES,
            NOT ( ISBLANK ( SALES[Customer Number] ) ),
            NOT ( ISBLANK ( SALES[Customer Name] ) ),
            NOT ( ISBLANK ( SALES[Customer Location] ) )
        ),
        "Customer Number", SALES[Customer Number],
        "Customer Name", SALES[Customer Name],
        "Customer Location", SALES[Customer Location]
    ))

Solution

  • Simply use the SELECTCOLUMNS() function from your question on both tables and then combine the result with the UNION() function.

    Result = 
    UNION (
        SELECTCOLUMNS ( SALES, ... ),
        SELECTCOLUMNS ( RETURNS, ...)
    )