Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Total amount on Latest date

Friends, 

 

i have product table, that contains product id,date,amount. i would like to get total amount on latest date latest value by index. For example on date 14-Nov, total amount will be (290+85) and when i select product id 4114 from slicer the total amount will be 290 only

 

 

4 Replies

    • Anonymous's avatar
      Anonymous
      Not applicable

      by default the date will be latest date from entire table. when we select date slicer. if we select 15 Sep the amount will be 111( or it will add also another product it will fell on 15 sep)

      • FreemanZ's avatar
        FreemanZ
        Super User

        Anonymous 

        try to create a measure with the code below:

        SumAmount =
        VAR Table1=
        SUMMARIZE(
            TableName,
            TableName[product_id],
            TableName[Date]
        )
        VAR Table2=
        ADDCOLUMNS(
            Table1,
            "Index",
            CALCULATE(MAX(TableName[Index]))
        )
        VAR MaxDate = MAX(TableName[Date])
        VAR Table3 =
        FILTER(
            Table2,
            TableName[Date] = MaxDate
            )
        VAR Table4 =
        TREATAS(
            Table3,
            TableName[product_id],
            TableName[Date],
            TableName[Index]
        )  
        VAR RESULT =
        CALCULATE(
            SUM(TableName[Amount]),
            Table4
        )
        RETURN
            RESULT
         
        I tried and it worked as below: