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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Employee
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
Employee
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors