Forum Discussion

Corlin's avatar
Corlin
Frequent Visitor
8 years ago
Solved

Field mismatch when using UNION

I am trying to combine two tables, but when I try to union them I get a mismatch between the fields as seen below. The goal is to create a table that contains all dates and filling the empty fields ...
  • v-cherch-msft's avatar
    8 years ago

    Hi Corlin

     

    You may have a look at UNION Function. To get the table as requested, the first way is to make sure the 'Date' column in WFOpenClosed table is the first column as below. Then you may get the table with your code.

     

    The second way is to change the code like below to get the table as requested.

    WFOpenClosedZeroFilled =
    UNION (
        SELECTCOLUMNS (
            WFOpenClosed,
            "date", WFOpenClosed[date],
            "Closed", WFOpenClosed[Closed],
            "WorkflowID", WFOpenClosed[WorkflowID],
            "Open", WFOpenClosed[Open]
        ),
        ADDCOLUMNS (
            EXCEPT ( VALUES ( 'calendar'[Date] ), VALUES ( WFOpenClosed[Date] ) ),
            "Closed", 0,
            "Open", 0,
            "WorkflowID", 0
        )
    )

    Regards,

    Cherie