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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
lazurens2
Frequent Visitor

Dax Measure to Specify which rows correspond to last change

Hello, 

 

I have this example please 

Expected output : a Measure that returns 1 for a = 3 / b = 6
These are verions and I need to specify which one is the last version

lazurens2_1-1663768350214.png

 

I tried this, the measure isn't even working because it couldn't find `_LastChange`

 

 

Best Score 2 = 
VAR _LastChange = SUMMARIZECOLUMNS('Table'[Column1],
"Maxd", Max('Table'[Column2])
)
VAR _group = VALUES('Table'[Column1])
VAR _max = _LastChange[Maxd]

Return 

VAR MaxValue =
    CALCULATE ( MAX ( 'Table'[Column2] ), REMOVEFILTERS ( 'Table' ) )
RETURN
    IF ( SELECTEDVALUE ( 'Table'[Column1] ) = _group, 
        IF(Filter('Table', 'Table'[Column1] = _group) = _max , 1, 0 )
)

 

 

 

Thank you in advance

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @lazurens2 

do you want to flag the last record of each value of column1? If so please try

Best Score 2 =
VAR CurrentValue =
    SELECTEDVALUE ( 'Table'[Column2] )
VAR MaxValue =
    CALCULATE ( MAX ( 'Table'[Column2] ), ALLEXCEPT ( 'Table', 'Table'[Column1] ) )
RETURN
    IF ( CurrentValue = MaxValue, 1 )

View solution in original post

2 REPLIES 2
tamerj1
Super User
Super User

Hi @lazurens2 

do you want to flag the last record of each value of column1? If so please try

Best Score 2 =
VAR CurrentValue =
    SELECTEDVALUE ( 'Table'[Column2] )
VAR MaxValue =
    CALCULATE ( MAX ( 'Table'[Column2] ), ALLEXCEPT ( 'Table', 'Table'[Column1] ) )
RETURN
    IF ( CurrentValue = MaxValue, 1 )

Thank you very much, it's working !

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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