Forum Discussion

vin90's avatar
vin90
Regular Visitor
2 years ago
Solved

Groupby and lookup values between tables using DAX

Hi Community. Could you please help me wth the following scenario?

I have tables: Table_1 and Table_2. I am trying to populate column Desired_Value in Table_1. 

This Desired_Value column should basically check for any Date (from Table_2) falling in the range of Start_Date and End_Date (from Table_1) for that particular ID and give me a grouped sum of Ind_Value (from Table_2). How to achieve this using DAX? Any help is appreciated.

 

Table_1:

IDStart_DateEnd_DateDesired_Value
11/08/202115/07/20233
116/07/20231/08/202316
21/08/202122/09/20238
31/08/202123/09/202310
410/03/202217/03/20222
418/03/20221/04/20233
51/02/202118/08/20231
61/02/202016/06/20231
71/07/20219/09/202212

 

Table_2:

IDDateInd_Value
112/07/20232
113/07/20231
121/07/20239
11/08/20237
212/07/20234
223/07/20234
34/08/202310
415/03/20222
429/03/20233
517/03/20231
615/04/20221
77/09/20215
78/09/20217

 

  • Desired Value = 
    var i = [ID]
    var b = Filter(Table_2,Table_2[ID]=i && Table_2[Date] in GENERATESERIES([Start_Date],[End_Date]))
    return sumx(b,[Ind_Value])

     

2 Replies

  • Desired Value = 
    var i = [ID]
    var b = Filter(Table_2,Table_2[ID]=i && Table_2[Date] in GENERATESERIES([Start_Date],[End_Date]))
    return sumx(b,[Ind_Value])