Forum Discussion

ramasaurio's avatar
ramasaurio
Frequent Visitor
2 years ago
Solved

Fill values that don't exist with values from another column

I have a table with a column with missing values, I want to fill those missing values with a column in another table.

I created this sample data as an example (sample_data.pbix) : 

 

Table A

datevalue_A
Friday, 13 September, 20241623
Sunday, 15 September, 20249584

 

Table B

datevalue_B
Friday, 13 September, 20245483
Saturday, 14 September, 20249084
Sunday, 15 September, 20241234

 

dates

dateweek_id
Friday, 13 September, 202437
Saturday, 14 September, 202437
Sunday, 15 September, 202438

 

The relationship between the tables are as follows using "date" as the key between them.

 

what I need to do is create a column with the values of column "value_A" from Table A, and fill the missing values (in this case the value for September 14th) with the values of "value_B". In this case, the column should have the values: 1623, 9084, 9584, for each date respectively.

I'm not really sure how to determine when a row in Table A doesn't exist. Table dates has the complete set of dates but I should leave that table intact. Table B may or may not have all the values, so I should leave a 0 if both Table A and Table B don't have that particular date.

Does anyone have directions for me to achieve this?

Thanks in advance.

 

2 Replies

    • ramasaurio's avatar
      ramasaurio
      Frequent Visitor

      Perfection.

      Thank you!

       

      Edit:

      The subtotals looks off, it show the same value as value_A. I'll play with it a bit more and see how it works.