Forum Discussion

Svenvdh's avatar
Svenvdh
Regular Visitor
5 years ago

Combine 2 tables with empty cells

The problem below occurs:
We have 2 database files. The first contains the number of hours per file number at activity level. In the second file you have the revenue amount per file number at activity level.
We want an overview of the number of hours spent and revenue made per file number per activity. But the activities do not have the same names and not every activity can be used for both the hours file and the turnover file.

Simplified example         
         
Database for the hours    Database for the revenue 
ActivityFile numberWorked ours  ActivityFile numberRevenue 
AAC12340,250  XYB1234 €  150,00 
AAD12340,125  XYD1235 €  200,00 
AAA12350,500  XYZ1236 €    25,00 
AAA12361,000  XYZ1236 €    75,00 
AAB12360,250  XYA1237 €  125,00 
AAC12360,125  XYD1237 €  175,00 
AAD12360,500  XYC1237 €    50,00 
AAC12371,000  XYB1238 €    25,00 
AAD12370,250  XYA1238 €  100,00 
         
So some activities are linked and others not. Like in the example below    
Linking table        
Activity hoursActivity revenue       
AAAXYZ       
AABXYA       
AAC        
 XYD       
AADXYC       
 XYB       
         
Now we want to see when the file number are the same if there are hours against the made revenue. 
File numberActivity revenueActivity hoursamountours    
1234XYZAAA €    50,000,500    
 XYAAAB €  100,001,000    
 XYB  €  150,000,000    
  AAC €           -  0,250    
  AAD €           -  0,125    
1235XYD  €  200,000,000    
1236XYZ AAA  €  100,001,000    
  AAB €           -  0,250    
  AAC €           -  0,125    
  AAD €           -  0,500    
1237XYA  €  125,000,000    
 XYD  €  175,000,000    
 XYCAAD €    50,000,250    
  AAC €           -  1,000    
1238XYB  €    25,000,000    
 XYA  €  100,000,000    

1 Reply

  • v-robertq-msft's avatar
    v-robertq-msft
    Icon for Community Support rankCommunity Support

    Hi, Svenvdh 

    According to your description and sample data, I can’t clearly understand what you want to get. Would you like to explain the columns in your expected output in detail(using some examples to explain why they are here and why their value is like this)?

     

    Thanks very much!

    How to Get Your Question Answered Quickly 

     

    Best Regards,

    Community Support Team _Robert Qin

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.