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
DataIsMyMN
Frequent Visitor

Latest & Earliest Date/Time Function Not Reporting Correctly

I have data that shows the date and time for file reciept; I am trying to create cards that show what the EARLIEST file receipt time was and what the LATEST file receipt time was in the given set of data. I have researched for quite some time and have not found anything to point me to the cause of why this is not reporting correctly... please help! 

 

Here is a sample of the data I am using:

DataIsMyMN_3-1678996068322.png

The earliest time a file was received should be reporting as from 1/24/2023 at 12:01:59 AM and the latest time a file was received should be reporting as 2/2/2023 at 12:16:00 PM; however, when I create a card visual and tell it to report earliest and latest from the Last File Receipt Time field, it is reporting this:

DataIsMyMN_1-1678996016704.png

I have even attempted to create new measures with MIN and MAX functions and it reports the same way.  

 

1 ACCEPTED SOLUTION

@DataIsMyMN Oh, you want the items with the min or max time regardless of date. If that is the case see attached PBIX below signature.

Earliest = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table',
            "Time", [Last File Receipt Time] - TRUNC([Last File Receipt Time])
        )
    VAR __MinTime = MINX(__Table, [Time])
    VAR __Result = MINX(FILTER(__Table, [Time] = __MinTime),[Last File Receipt Time])
RETURN
    __Result
Latest = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table',
            "Time", [Last File Receipt Time] - TRUNC([Last File Receipt Time])
        )
    VAR __MaxTime = MAXX(__Table, [Time])
    VAR __Result = MINX(FILTER(__Table, [Time] = __MaxTime),[Last File Receipt Time])
RETURN
    __Result

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
DataIsMyMN
Frequent Visitor

@Greg_Deckler yes, it is a Date/Time column.  I've tried changing the display format to only show the time, but that doesn't fix it. 

@DataIsMyMN Oh, you want the items with the min or max time regardless of date. If that is the case see attached PBIX below signature.

Earliest = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table',
            "Time", [Last File Receipt Time] - TRUNC([Last File Receipt Time])
        )
    VAR __MinTime = MINX(__Table, [Time])
    VAR __Result = MINX(FILTER(__Table, [Time] = __MinTime),[Last File Receipt Time])
RETURN
    __Result
Latest = 
    VAR __Table = 
        ADDCOLUMNS(
            'Table',
            "Time", [Last File Receipt Time] - TRUNC([Last File Receipt Time])
        )
    VAR __MaxTime = MAXX(__Table, [Time])
    VAR __Result = MINX(FILTER(__Table, [Time] = __MaxTime),[Last File Receipt Time])
RETURN
    __Result

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler, you are a LIFESAVER, thank you!  This worked beautifully! 

Greg_Deckler
Super User
Super User

@DataIsMyMN Is that column a Date/Time column?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.