Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

opening stock

LastDateInPreviousMonth = VAR SelectedDate = MAX('TT sellout 2023 to date'[Date]) VAR PreviousMonthStartDate = EOMONTH(SelectedDate, -2) + 1 VAR PreviousMonthEndDate = EOMONTH(SelectedDate, -1) ...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi  Anonymous ,

     

    You might consider using the SELECTEDVALUE() function to get the specific product or a specific category:

    Opening Stock Previous Month =
    VAR LastDateInPrevMonth = [LastDateInPreviousMonth]
    VAR SelectProduct=SELECTEDVALUE('TT sellout 2023 to date'[Product])
    VAR SelectCategory=SELECTEDVALUE('TT sellout 2023 to date'[category])
    RETURN
        CALCULATE(
            SUM('TT sellout 2023 to date'[Inventory in Cases]),
            FILTER(
                ALL('TT sellout 2023 to date'),
                'TT sellout 2023 to date'[Date] = LastDateInPrevMonth&&
                'TT sellout 2023 to date'[Product]=SelectProduct &&
                'TT sellout 2023 to date'[category]=SelectCategory
            )
        )

     

    Best Regards,

    Liu Yang

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.