Forum Discussion
Anonymous
3 years agoNot applicable
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
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)RETURNRESULTI tried and it worked as below:
4 Replies
- FreemanZSuper User
why skip product 2116?
- AnonymousNot 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)
- FreemanZSuper 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)RETURNRESULTI tried and it worked as below: