Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
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 with zeroes.
The calendar contains "dates"
WFOpenClosed contains "dates", "Open", "Closed", "WorkflowID"
I have been trying to follow this implementation.
Any help with my problem would be greatly appreciated.
I am using the following code to populate the table:
WFOpenClosedZeroFilled = UNION ( WFOpenClosed; ADDCOLUMNS ( EXCEPT ( VALUES ( 'calendar'[Date] ); VALUES ( WFOpenClosed[Date] ) ); "Open"; 0; "Closed"; 0; "WorkflowID"; 0 ) )
Closed and Date is swapped in the union.
Solved! Go to Solution.
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
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
Thank you for your input, I ended up using the SELECTCOLUMN to solve my problem.
@Corlin Please post the sample input data and your expected output as well, which will be helpful to understand and resolve your issue quickly.....
Proud to be a PBI Community Champion
My input data is the bottom half of the image.
The value seen in the Date column in the bottom half is decimal number corresponding to a date, and as you can see are the upper half of the rows inputted wrong as the date gets in the Closed column and the Closed value in the Date column
What I want to achieve is inserting 0 for the closed, open and WorkflowID for the days nothing were logged as seen below.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
99 | |
88 | |
70 | |
62 |
User | Count |
---|---|
151 | |
120 | |
103 | |
87 | |
68 |