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

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

Reply
zogamorph
New Member

Measure to get the earliest last date

Hi All 

  I would like to know if it possible to create a measure that get the earliest last date from table with a date and work it base and work with the filter context? 

 

Have the following table: 

Log Table

Customer IdMachine Id Log DateValue
1a2021-01-22250
1a2021-01-23265
2b2021-01-22500
2b2021-01-24356
3c2021-01-25265
3c2021-01-26541
4d2021-01-23524
4d2021-01-24365

 

Customer 

Customer RegionCustomer AreaCustomer Id
zv1
zv2
zw3
xy4

 

I would like the measure create the following results

 

Customer RegionEarlist Last Date
z2021-01-23
x2021-01-24

 

Then next level

 

Customer RegionCustomer AreaEarlist Last Log Date
zv2021-01-23
zw2021-01-26
xy2021-01-24

 

I try create the measure like

 

'Log Table'[Last Script Log Date] =
VAR CurrentLastDate = MINX(
CALCULATETABLE('Log Table',
'Log Table'[MachineId] = 'Log Table'[MachineId]
, LASTDATE('Log Table'[Log Date])
)
,'Log Table'[Log Date])
RETURN IF(ISBLANK( CurrentLastDate ),DATE(1,1,1),CurrentLastDate )

 

 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure expression, replacing T1 for your actual table name.

 

Min Max =
VAR vMaxDates =
    SUMMARIZE (
        T1,
        T1[Customer Id],
        "cMaxDate"MAX ( T1[Log Date] )
    )
RETURN
    MINX (
        vMaxDates,
        [cMaxDate]
    )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Microsoft Employee
Microsoft Employee

Please try this measure expression, replacing T1 for your actual table name.

 

Min Max =
VAR vMaxDates =
    SUMMARIZE (
        T1,
        T1[Customer Id],
        "cMaxDate"MAX ( T1[Log Date] )
    )
RETURN
    MINX (
        vMaxDates,
        [cMaxDate]
    )

 

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


rfigtree
Resolver III
Resolver III

had trouble interpreting your question. 

best guess.

mFirstLogDate:=MIN(tblLog[Date])
mLastLogDate:=MAX(tblLog[Date])

 

rfigtree_1-1613171480922.png

 

 

rfigtree_0-1613171375567.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

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.