Forum Discussion
Get Previous Running Total for Missing Month
- 6 years ago
Hi, Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
ShipQty:
Date:
Date = CALENDAR(DATE(2001,1,1),DATE(2022,12,31))There is a relationship between two tables.
You may create calculated columns and a measure as below.
Calculated column: YearMonth = VALUE(FORMAT('Date'[Date],"yyyymm")) YearMonthDay = FORMAT('Date'[Date],"yyyy-mm-"&"01") YearMonth2 = VALUE(FORMAT(ShipQty[Date],"yyyymm")) Measure: Result = CALCULATE( SUM(ShipQty[Qty]), FILTER( ALL(ShipQty), ShipQty[Item] = SELECTEDVALUE(ShipQty[Item])&& ShipQty[YearMonth2]<=SELECTEDVALUE('Date'[YearMonth]) ) )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, Anonymous
Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.
ShipQty:
Date:
Date = CALENDAR(DATE(2001,1,1),DATE(2022,12,31))
There is a relationship between two tables.
You may create calculated columns and a measure as below.
Calculated column:
YearMonth = VALUE(FORMAT('Date'[Date],"yyyymm"))
YearMonthDay = FORMAT('Date'[Date],"yyyy-mm-"&"01")
YearMonth2 = VALUE(FORMAT(ShipQty[Date],"yyyymm"))
Measure:
Result =
CALCULATE(
SUM(ShipQty[Qty]),
FILTER(
ALL(ShipQty),
ShipQty[Item] = SELECTEDVALUE(ShipQty[Item])&&
ShipQty[YearMonth2]<=SELECTEDVALUE('Date'[YearMonth])
)
)
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.