Forum Discussion

pbi_sm's avatar
pbi_sm
New Member
2 years ago
Solved

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...
  • LufengYuan's avatar
    2 years ago

    Try the below measure ... seems to work.

    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)