Forum Discussion
Append tables that include columns created by DAX using Power Query
I am combining data from two different systems in order to make a report on Power BI.
Old data looks like this. Only one row per day.
| Date | Category | Details |
| 01/01/2020 | A | blah blah |
| 01/02/2020 | B | yada yada |
New data looks like this.
| Date | New Category | New Subcategory | Details |
01/03/2020 | C | E | blah blah |
01/03/2020 | D | F | yada yada |
01/04/2020 | D | G | lalalalala |
Say we switch to the new system by 01/03/2020. I need these two tables to be combined to one table, where data before 01/03/2020 to be pulled from old data, and data after 01/03/2020 to be pulled from new data. I had recoded [Category] from old data to [New Category] and [New Subcategory] using DAX (use Switch to create a column), and I would like to stack these two tables together like the following
| Date | New Category | New Subcategory | Details |
| 01/01/2020 | (recoded to) C | (recoded to) F | blah blah |
| 01/02/2020 | (recoded to) C | (recoded to) G | yada yada |
01/03/2020 | C | E | blah blah |
01/03/2020 | D | F | yada yada |
01/04/2020 | D | G | lalalalala |
How can I make that happen? I cannot append these two tables using Power Query because columns created using DAX are invisible in Power Query. I am very stuck... help!
Anonymous You can use the UNION function to combine two tables in DAX, but I would strongly look at the calculated columns you created in DAX and see if you can push them back into Power Query. I avoid Calculated Columns at all costs. Then you can easily use the Append (Table.Combine()) functionality in Power Query. Remember, modeling is best done in Power Query, and Analysis is best done in DAX. Appending tables and adding columns is generally a modeling issue, and should be done in DAX in the rarest of cases.
In general, try to avoid calculated columns. There are times to use them, but it is rare. Getting data out of the source system, creating columns in Power Query, or DAX Measures are usually preferred to calculated columns. See these references:
Calculated Columns vs Measures in DAX
Calculated Columns and Measures in DAX
Storage differences between calculated columns and calculated tables
Creating a Dynamic Date Table in Power Query
3 Replies
- parry2kSuper User
Anonymous I would recommend either create new table using UNION function in DAX or append table in Power Query. That is the best use case for you.
I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
⚡Visit us at https://perytus.com, your one-stop shop for Power BI related projects/training/consultancy.⚡
- edhansCommunity Champion
Anonymous You can use the UNION function to combine two tables in DAX, but I would strongly look at the calculated columns you created in DAX and see if you can push them back into Power Query. I avoid Calculated Columns at all costs. Then you can easily use the Append (Table.Combine()) functionality in Power Query. Remember, modeling is best done in Power Query, and Analysis is best done in DAX. Appending tables and adding columns is generally a modeling issue, and should be done in DAX in the rarest of cases.
In general, try to avoid calculated columns. There are times to use them, but it is rare. Getting data out of the source system, creating columns in Power Query, or DAX Measures are usually preferred to calculated columns. See these references:
Calculated Columns vs Measures in DAX
Calculated Columns and Measures in DAX
Storage differences between calculated columns and calculated tables
Creating a Dynamic Date Table in Power Query - daxCommunity Support
Hi Anonymous ,
You could refer to edhans and parry2k 's suggestions to combine table. In addition, if possible, could you please explain the logic of first two rows, why it show C and F , G? Is this based other value or just fixed value? Then I will try to understand it and test this in my environment.
Date New Category New Subcategory Details 01/01/2020 (recoded to) C (recoded to) F blah blah 01/02/2020 (recoded to) C (recoded to) G yada yada Best Regards,
Zoe Zhi