Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not 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

 

jia0077_0-1669623962598.png

 

2 ACCEPTED SOLUTIONS

@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:
FreemanZ_0-1669639874833.png
 
FreemanZ_1-1669639889773.png

 

View solution in original post

4 REPLIES 4
FreemanZ
Super User
Super User

why skip product 2116?

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)

@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:
FreemanZ_0-1669639874833.png
 
FreemanZ_1-1669639889773.png

 

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.