Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
clarkbj71
Helper I
Helper I

Creating new table from columns from existing tables, summing 2 of the columns

Below is a generic example of my data although I have 10 tables I need to group into one rather then the 3 below in my example:  I want to sum Number1 and Number 2 and group by Date, Country and Type.  I cannot do this in the Query Editor as the calculations for Number 1 and Number 2 have to be done after the data is loaded.  I have explored Union, Group by, Summarize but having trouble with the grouping all the tables together.   

Table1    
DateCountyTypeNumber1Number2
1/1/2019USAA77020.002
2/1/2019USAB53010.3
3/1/2019USAC65420.543
4/1/2019USAD00.653
1/1/2019GermanyA86530.5
2/1/2019GermanyB00.25
3/1/2019GermanyC42121.5
4/1/2019GermanyD50
1/1/2019MexicoA65420.543
2/1/2019MexicoA55420.643
3/1/2019MexicoA45420.743
4/1/2019MexicoA35420.843
1/1/2019RussiaA00.653
2/1/2019RussiaB10.753
3/1/2019RussiaC20.853
4/1/2019RussiaD30.953
     
Table2    
DateCountyTypeNumber1Number2
1/1/2019USAA77020.002
2/1/2019USAB77050.004
3/1/2019USAC77080.006
4/1/2019USAD77110.008
1/1/2019GermanyA77140.01
2/1/2019GermanyB77170.012
3/1/2019GermanyC77200.014
4/1/2019GermanyD77230.016
1/1/2019MexicoA77260.018
2/1/2019MexicoA77290.02
3/1/2019MexicoA77320.022
4/1/2019MexicoA77350.024
1/1/2019RussiaA77380.026
2/1/2019RussiaB77410.028
3/1/2019RussiaC77440.03
4/1/2019RussiaD77470.032
     
Table3    
DateCountyTypeNumber1Number2
1/1/2019USAA55400.003
2/1/2019USAB53010.013
3/1/2019USAC50620.023
4/1/2019USAD48230.033
1/1/2019GermanyA45840.043
2/1/2019GermanyB43450.053
3/1/2019GermanyC41060.063
4/1/2019GermanyD38670.073
1/1/2019MexicoA36280.083
2/1/2019MexicoA33890.093
3/1/2019MexicoA31500.103
4/1/2019MexicoA29110.113
1/1/2019RussiaA26720.123
2/1/2019RussiaB24330.133
3/1/2019RussiaC21940.143
4/1/2019RussiaD19550.153
6 REPLIES 6
negi007
Community Champion
Community Champion

@clarkbj71  You can easily achieve it by appending tables in power query window

 

Select all 10 tables in the powerquery window then select append queries as new. You will get one table having values from all 10 tables. like below.  Please make sure all tables are having same column header. You can then uncheck "enabled load option" for all 10 tables so that you have only one table in the powerbi. Once you have appended all the 10 tables into one, you can either create a column to have the sum of number1 and number 2 in power query window or create a measure in the powerbi desktop that will sum two values.

 

negi007_0-1602336423774.png

 




Did I answer your question? Mark my post as a solution!
Appreciate your Kudos



Proud to be a Super User!


Follow me on linkedin

Sent a reply to you earlier but looks like it didn't go through.  I would love to be able to use append in Query Editor but in order to create the values in Number 1 and Number 2 I had to use about 35 measures, all using different base data.  I did try doing these calculations in Query Editor with Calculated Columns but it really bogged down Power BI so switched back to using the measures which required me to create the 10 different tables.  See my reply earlier to what I am trying to create.  A measure to sum the values from the tables does not work in my visual as I can't get a legend and my slicers don't seem to work for all the visuals which is why I was hoping to create one table from the 10 but just can't get the DAX correct in combining more than two tables.

pranit828
Community Champion
Community Champion

Hi @clarkbj71 

I don't understant why you want to group it in the table itself.

groups are automatically done in the table or matrix visual.

Create a UNION table on Power BI Desktop and create a Sum column in the new union table.

Use 'Table' chart and select the columns on order which you want it to be grouped and select the summed column in the bottom.

 





PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

Sorry my example was a bit off.  My data looks more like this below:  I am looking to create 4 visuals (stacked bar charts), 2 for number 1 and two for number 2.  One by Country and one by Type (in Legend) with Date in X axis and 2 slicers -Country and Type where all graphs filter correclty.  I created three addition lookup tables for my data model (Country, Type and Date) and connected all my other tables to these.  Originally I tried to create a measure to caluclate the sum but the slicers were not filtering all the visuals correctly. Plus I could not use a legend when I used the total measure.  I thought I could avoid all this if I could combine the seperate tables into one.  I am just struggling on how to write the DAX to create the combined table when dealing with more than 2.

Table1    
DateCountyTypeNumber1Number2
1/1/2019USAA77020.002
2/1/2019USAB53010.3
3/1/2019USAC65420.543
4/1/2019USAD00.653
1/1/2019GermanyA86530.5
2/1/2019GermanyB00.25
3/1/2019GermanyC42121.5
4/1/2019GermanyD50
1/1/2019MexicoA65420.543
2/1/2019MexicoA55420.643
3/1/2019MexicoA45420.743
4/1/2019MexicoA35420.843
1/1/2019RussiaA00.653
2/1/2019RussiaB10.753
3/1/2019RussiaC20.853
4/1/2019RussiaD30.953
     
Table2    
DateCountyTypeNumber1Number2
1/1/2019USAA77020.002
2/1/2019USAB77050.004
3/1/2019USAC77080.006
4/1/2019USAD77110.008
1/1/2019GermanyA77140.01
2/1/2019GermanyB77170.012
3/1/2019GermanyC77200.014
4/1/2019GermanyD77230.016
1/1/2019MexicoA77260.018
2/1/2019MexicoA77290.02
3/1/2019MexicoA77320.022
4/1/2019MexicoA77350.024
1/1/2019RussiaA77380.026
2/1/2019RussiaB77410.028
3/1/2019RussiaC77440.03
4/1/2019RussiaD77470.032
     
Table3    
DateCountyTypeNumber1Number2
1/1/2019USAA55400.003
2/1/2019USAB53010.013
3/1/2019USAC50620.023
4/1/2019USAD48230.033
1/1/2019GermanyA45840.043
2/1/2019GermanyB43450.053
3/1/2019GermanyC41060.063
4/1/2019GermanyD38670.073
1/1/2019MexicoA36280.083
2/1/2019MexicoA33890.093
3/1/2019MexicoA31500.103
4/1/2019MexicoA29110.113
1/1/2019RussiaA26720.123
2/1/2019RussiaB24330.133
3/1/2019RussiaC21940.143
4/1/2019RussiaD19550.153

Hi,

The Append feature of Power Query should work very well.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Yes append would work great if I could do it in Query Editor but I cannot due to multiple measures (35) I had to create in order to get my two columms of data.  I did figure it out though.  I was trying to make it too complicated and thought I would need to use Union(SelectColumns) but all I needed was Union(Table1, Table2, Table2, etc.). 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.