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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
JamieH
Helper I
Helper I

Measure to get value of last row by 2 by groups

I have a table called Performance which has many columns.  The main columns are Acc, MonthEndDate and Flag.

For each Acc there is a row for each MonthEndDate.  I'd like to bring back the flag for the most recent MonthEndDate for each Acc.

Example:

Have

AccMonthEndDateFlag
131/07/20220
131/08/20221
130/09/20221
131/10/20220
231/08/20220
230/09/20220
231/10/20221

 

Want

AccFlag
10
21

 

Thanks

 

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

If you know that there will be 1 entry per Acc for every date then you can use

Most recent flag =
VAR MaxDate =
    MAX ( 'Table'[Date] )
VAR ReferenceAcc =
    SELECTEDVALUE ( 'Table'[Acc] )
VAR Result =
    LOOKUPVALUE (
        'Table'[Flag],
        'Table'[Acc], ReferenceAcc,
        'Table'[Date], MaxDate
    )
RETURN
    Result

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

If you know that there will be 1 entry per Acc for every date then you can use

Most recent flag =
VAR MaxDate =
    MAX ( 'Table'[Date] )
VAR ReferenceAcc =
    SELECTEDVALUE ( 'Table'[Acc] )
VAR Result =
    LOOKUPVALUE (
        'Table'[Flag],
        'Table'[Acc], ReferenceAcc,
        'Table'[Date], MaxDate
    )
RETURN
    Result

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors