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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
kleysonr
Frequent Visitor

Max value of a datetime per category

Hi,

 

I have the following table:

 

sample.png

 

I need to create an individual measure for each category Table[Name] getting the Table[Value] for the Lastdate of the category.

 

My last try was the below, but no success:

 

Last Value of A = 
  var _name = "A"
  var _lastdate = LASTDATE(MyTable[Datetime])
  var _maxvalue = CALCULATE(
    MAX(MyTable[Value]),
    FILTER(
        all(MyTable),
        MyTable[Datetime] = _lastdate && MyTable[Name] = _name
    )
)
return _maxvalue
 

 

This table is supposed to be big because it's receiving streaming data and keeping the history.

 

How to create a measure that give me the last value of A considering the performance for calculation on a streaming table ?

 

Best Regards.
Kleyson Rios.

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @kleysonr 

if you are slicing by name in your visual then delete the name filter part

Last Value of A =
VAR _name = "A"
VAR _lastRecod =
TOPN ( 1, FILTER ( MyTable, MyTable[Name] = _name ), MyTable[Datetime] )
VAR _maxvalue =
SUMX ( _lastRecod, MyTable[Value] )
RETURN
_maxvalue

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @kleysonr 

if you are slicing by name in your visual then delete the name filter part

Last Value of A =
VAR _name = "A"
VAR _lastRecod =
TOPN ( 1, FILTER ( MyTable, MyTable[Name] = _name ), MyTable[Datetime] )
VAR _maxvalue =
SUMX ( _lastRecod, MyTable[Value] )
RETURN
_maxvalue

Thanks.

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.