Forum Discussion
Cummulative sum with reference date in another table
- 6 years ago
Hi, cferraz_hemav
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table1:
Table2:
There is no relationship between two tables. You may create a measure or a calculated column as below.
Measure:
Accumulated Measure = var _fieldid = SELECTEDVALUE(Table2[field_id]) var _infodate = SELECTEDVALUE(Table2[info_date]) var _startdate = LOOKUPVALUE(Table1[start_date],Table1[field_id],_fieldid) var result = CALCULATE( SUM(Table2[data]), FILTER( ALL(Table2), Table2[field_id]=_fieldid&& Table2[info_date]>=_startdate&& Table2[info_date]<=_infodate ) ) return IF( ISBLANK(result), 0, result )Calculated column:
Accumulated Column = var _fieldid = Table2[field_id] var _infodate = Table2[info_date] var _startdate = LOOKUPVALUE(Table1[start_date],Table1[field_id],_fieldid) var result = CALCULATE( SUM(Table2[data]), FILTER( ALL(Table2), Table2[field_id]=_fieldid&& Table2[info_date]>=_startdate&& Table2[info_date]<=_infodate ) ) return IF( ISBLANK(result), 0, result )Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, cferraz_hemav
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
Table1:
Table2:
There is no relationship between two tables. You may create a measure or a calculated column as below.
Measure:
Accumulated Measure =
var _fieldid = SELECTEDVALUE(Table2[field_id])
var _infodate = SELECTEDVALUE(Table2[info_date])
var _startdate =
LOOKUPVALUE(Table1[start_date],Table1[field_id],_fieldid)
var result =
CALCULATE(
SUM(Table2[data]),
FILTER(
ALL(Table2),
Table2[field_id]=_fieldid&&
Table2[info_date]>=_startdate&&
Table2[info_date]<=_infodate
)
)
return
IF(
ISBLANK(result),
0,
result
)
Calculated column:
Accumulated Column =
var _fieldid = Table2[field_id]
var _infodate = Table2[info_date]
var _startdate =
LOOKUPVALUE(Table1[start_date],Table1[field_id],_fieldid)
var result =
CALCULATE(
SUM(Table2[data]),
FILTER(
ALL(Table2),
Table2[field_id]=_fieldid&&
Table2[info_date]>=_startdate&&
Table2[info_date]<=_infodate
)
)
return
IF(
ISBLANK(result),
0,
result
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- cferraz_hemav6 years agoHelper I
Thank you very much for your time and fast reply v-alq-msft !!