Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
pbi_sm
New Member

Roll forward / duplicate values from current period into future

Hey there

 

i currently struggle with a specific problem: I have two different tables in a bigger datamodel which are connected via 1:n relationshiop. One table contains inventory data per site for different materials. The other contains forecast values. So the inventory table only has values for past and current period. The other has past, current and future. Now iw ant to create a measure or calculated column which displays values from the inventory data up to the current period and rolls forward or duplicates the most recent values into future periods. I need this for other calculations with the future periods from forecasts and other tables.

 

I attached a example file with a reduced version of the data model and also the screenshot below so you can understand the idea:

https://file.io/JEHTBY4rtGNW

It wont let me attach the .pbix file directly into this post - sorry.

 

ForecastDeliveries is from Table "Forecasts" (includes future periods) and "Summe von Amount" is from the "Inventory" table (includes only past and current periods. The calculated column or measure should behave like "Summe von Amount" but including the forward duplication of the most recent values for each combination of Period, Site and Material (green). The combination of Period_SiteID_MaterialID is also the Key which connects both tables (eg. 202312_200_100).

pbi_sm_0-1705343066871.png

In my original datamodel i tried so many solutions but the values for future periods always stays blank. Hope somebody can help. Thanks in advance and kind regards.

 

1 ACCEPTED SOLUTION
LufengYuan
Frequent Visitor

Try the below measure ... seems to work.

LufengYuan_0-1705372366099.png

Sum of Amount Test =
var _currentPeriod = MAX('Forecasts'[Period])

var _currentSite = MAX('Forecasts'[Site])
var _currentMaterial = MAX('Forecasts'[Material])
var _lastPeriod = CALCULATE(
                    MAX('Inventory'[Period]),
                    FILTER(
                    ALL('Inventory'),
                    'Inventory'[Period] <_currentPeriod &&
                    'Inventory'[Site] = _currentSite &&
                    'Inventory'[Material] = _currentMaterial
                    )
)
var _result =
CALCULATE(
    SUM('Inventory'[Amount]),
    FILTER(
        ALL('Inventory'),
    'Inventory'[Period] = _lastPeriod &&
    'Inventory'[Site] = _currentSite &&
    'Inventory'[Material]= _currentMaterial
))
RETURN IF( ISBLANK(_result), SUM('Inventory'[Amount]), _result)

View solution in original post

2 REPLIES 2
LufengYuan
Frequent Visitor

Try the below measure ... seems to work.

LufengYuan_0-1705372366099.png

Sum of Amount Test =
var _currentPeriod = MAX('Forecasts'[Period])

var _currentSite = MAX('Forecasts'[Site])
var _currentMaterial = MAX('Forecasts'[Material])
var _lastPeriod = CALCULATE(
                    MAX('Inventory'[Period]),
                    FILTER(
                    ALL('Inventory'),
                    'Inventory'[Period] <_currentPeriod &&
                    'Inventory'[Site] = _currentSite &&
                    'Inventory'[Material] = _currentMaterial
                    )
)
var _result =
CALCULATE(
    SUM('Inventory'[Amount]),
    FILTER(
        ALL('Inventory'),
    'Inventory'[Period] = _lastPeriod &&
    'Inventory'[Site] = _currentSite &&
    'Inventory'[Material]= _currentMaterial
))
RETURN IF( ISBLANK(_result), SUM('Inventory'[Amount]), _result)

Thank you, that worked! I just changed "  'Inventory'[Period] <_currentPeriod &&" to "  'Inventory'[Period] =<_currentPeriod &&" because otherwise it would always display the values from one period before, even when looking at past periods. 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.