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
michaelu1
Helper II
Helper II

Max date without time

I'm trying to calculate the most recent note based on a users note history.  Part of that involves making sure that the date of the note ('Note Detail'[LASTDATE]) is the same date as the call ('Call History'[Date]), both columns are data type "date" not date/time.


The issue that I'm having is that when I calculate the MAX of a date I get a timestamp even though that column has a data type of date. I got around it by comparing the year/month/day - highlighted red.

 

Is there a better way to do this?

Note Text =
VAR _NameID = MAX('Call History'[NameID])
VAR _Date = MAX('Call History'[Date])
VAR _UName = MAX('Call History'[Name2])
VAR _Text =
CALCULATE(
    MAX('Note Detail'[NOTETEXT]),
        'Note Detail'[NAMEID]=_NameID,
        MONTH('Note Detail'[LASTDATE])=MONTH(_Date) && YEAR('Note Detail'[LASTDATE]) = YEAR(_Date) && DAY('Note Detail'[LASTDATE])=DAY(_Date),
        'Note Detail'[User Name]=_UName
)
4 REPLIES 4
v-zhangti
Community Support
Community Support

Hi, @michaelu1 

 

Can you provide sample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures or Excel. I look forward to your response.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

I don't have a sample data set, but I can try to get one one if needed. 

 

Very simply, if I have a date equaling 3/3/2023 10:58:23 AM and my filter context is set to 3/3/23, how can I get MAX(date) to equal my date? The issue being that MAX automatically adds on 12:00:00 AM and now they are no longer equal.

michaelu1
Helper II
Helper II

I just realized that I had this set up as a date type in the data view, not in the Query Editor. I switched the type there and that solved my problem.

However, is there a to keep the time and still compare just the date without having to jump through these hoops?

Hi,

In the Query Editor, you may create another column which extract the Date from the Date/time column.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.