Forum Discussion
Adding data depending on 2 links : an ID and a date
- 5 years ago
Hi Charlesdudu ,
According to your needs, based on the date as the judgment condition, two measures are created to get the correct results. Refer to the following:nlocation = VAR _sensorid = SELECTEDVALUE ( 'Table2'[Sensor ID] ) VAR _curdate = SELECTEDVALUE ( 'Table2'[Date of measure] ) VAR _insdate = CALCULATE ( MAX ( 'Table1'[Installation date] ), FILTER ( 'Table1', 'Table1'[Sensor ID] = _sensorid && 'Table1'[Uninstallation date] <> BLANK () ) ) VAR _uinsdate = CALCULATE ( MAX ( 'Table1'[Uninstallation date] ), FILTER ( 'Table1', 'Table1'[Sensor ID] = _sensorid && 'Table1'[Uninstallation date] <> BLANK () ) ) VAR _insdate1 = CALCULATE ( MAX ( 'Table1'[Installation date] ), FILTER ( 'Table1', 'Table1'[Sensor ID] = _sensorid && 'Table1'[Uninstallation date] = BLANK () ) ) VAR _location = CALCULATE ( MAX ( 'Table1'[Location] ), FILTER ( 'Table1', 'Table1'[Sensor ID] = _sensorid && 'Table1'[Uninstallation date] <> BLANK () ) ) VAR _location1 = CALCULATE ( MAX ( 'Table1'[Location] ), FILTER ( 'Table1', 'Table1'[Sensor ID] = _sensorid && 'Table1'[Uninstallation date] = BLANK () ) ) RETURN IF ( _curdate >= _insdate && _curdate <= _uinsdate, _location, _location1 )
If the problem is still not resolved, please provide detailed error information. Let me know immediately, looking forward to your reply.Best Regards,
HenryIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Charlesdudu , Create a new column in table 2
New column =
maxx(filter(Table1, table1[Sensor ID] = table2[Sensor ID] && table2[Date of measure] >= table1[Installation date] && (table2[Date of measure] <= table1[Uninstallation date]
|| isblank(table1[Uninstallation date]))), Table1[Location])
Hello,
Thank you for your answer.
I manage to compare the date of both tables using the formula "RELATED" and creating a relation n:n between Tabel 1 and Table 2 on the Field "Sensor ID".
But I have an error : "Column 'Table1[Sensor ID]' doesn't exist or doesn't have relation with an existing table in the actual context"
How should I overpass this problem ?
Thank you