Forum Discussion

M_SBS_6's avatar
M_SBS_6
Helper V
1 year ago
Solved

Month End Values

  Hi, I have a list of data that comes into us everyday, Monday to Friday. What I need to show is the values based on the last date we have each month.    My table as an example:   Date.        ...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi M_SBS_6 

     

    For your question, here is the method I provided:

     

    Here's some dummy data

     

    “Table”

     

     

    Create a new column, [YearMonth], containing the year and month.

     

    YearMonth = FORMAT('Table'[Date], "YYYY-MM")

     

    Create a measure to extract the last date of each month.

     

    LastDateOfMonth = 
    CALCULATE(
        MAX('Table'[Date]),
        ALLEXCEPT('Table', 'Table'[YearMonth])
    )

     

    Create two measures to calculate the totals of "Nike" and "Macron" respectively.

     

    Nike TotalValueAtMonthEnd = 
    CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            'Table',
            'Table'[Date] = 'Table'[LastDateOfMonth]
            &&
            CONTAINSSTRING('Table'[Name], "Nike")
        )
    )
    

     

    Macron TotalValueAtMonthEnd = 
    CALCULATE(
        SUM('Table'[Value]),
        FILTER(
            'Table',
            'Table'[Date] = 'Table'[LastDateOfMonth]
            &&
            CONTAINSSTRING('Table'[Name], "Macron")
        )
    )
    

     

    Here is the result.

     

     

    Regards,

    Nono Chen

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