Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

How to Show Contiguous Sum Trend Based on Timestamped Value Table

I am being provided a dataset from Cost Accounting that has the list of all costed Parts and the time that part was costed (and a "Product" is generally made of multiple costed "Parts"). When a Part'...
  • v-alq-msft's avatar
    6 years ago

    Hi, Anonymous 

     

    Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

    Table:

     

    Calendar(a calculated table):

    Calendar = CALENDARAUTO()

     

    There is no relationship between two tables. You may create a measure as below.

    Result = 
    var tab = 
    ADDCOLUMNS(
        SUMMARIZE(
            FILTER(
                ALL('Table'),
                'Table'[Update Date]<=SELECTEDVALUE('Calendar'[Date])
            ),
            'Table'[Product Name],
            'Table'[Part Number],
            "MaxDate",MAX('Table'[Update Date])
        ),
        "Cost",
        CALCULATE(
            SUM('Table'[Part Cost]),
            FILTER(
                ALL('Table'),
                'Table'[Product Name]=EARLIER('Table'[Product Name])&&
                'Table'[Part Number]=EARLIER('Table'[Part Number])&&
                'Table'[Update Date]=EARLIER([MaxDate])
            )
        )
    )
    return
    SUMX(
        FILTER(
            tab,
            [Product Name]=SELECTEDVALUE('Table'[Product Name])
        ),
        [Cost]
    )

     

    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.