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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
learner03
Post Partisan
Post Partisan

Calculate Max and Min from another table

How can I get value for MAX timestamp and MIN timestamp in Table 1 from Table 2 as per below scenerio-

 

akapoor03_0-1626921321519.png

 

 

1 ACCEPTED SOLUTION

@learner03 apologies, I didn't catch that requirement in your initial description.

How about these:

MIN Timestamp = 
VAR _USERNAME = Table1[UserName]
VAR _DATE = FORMAT(Table1[Date], "dd/mm/yyyy")
VAR _Result = 
CALCULATE(
    MIN(Table2[Timestamp]),
    Table2[User] = _USERNAME,
    FORMAT(Table2[Timestamp], "dd/mm/yyyy") = _DATE
)
Return
_Result

 

MAX Timestamp = 
VAR _USERNAME = Table1[UserName]
VAR _DATE = FORMAT(Table1[Date], "dd/mm/yyyy")
VAR _Result = 
CALCULATE(
    MAX(Table2[Timestamp]),
    Table2[User] = _USERNAME,
    FORMAT(Table2[Timestamp], "dd/mm/yyyy") = _DATE
)
Return
_Result

View solution in original post

4 REPLIES 4
ebeery
Memorable Member
Memorable Member

@learner03 assuming you are trying to do this as a calculated column in Table 1, you could use something like:

MIN Timestamp = 
VAR _USERNAME = Table1[UserName]
RETURN
CALCULATE(
    MIN(Table2[Timestamp]),
    Table2[User] = _USERNAME
)

and

 

MAX Timestamp = 
VAR _USERNAME = Table1[UserName]
RETURN
CALCULATE(
    MAX(Table2[Timestamp]),
    Table2[User] = _USERNAME
)

 

Thanks . Just a follow up Question--

How can I get difference of the Start and end time in hours (like whole number example 5,6.5 etc)-

akapoor03_0-1626931333644.png

 

 

I tried with this, but getting minimum time from whole Table 2 and Max time from whole Table 2 like below-

akapoor03_0-1626923183782.png

 

where as I want min time of 21/07/201 and Max time of 21/07/201, and similarly min time of 22/07 amd max time of 22/07 and so on . So, basically min and max time of the date.

@learner03 apologies, I didn't catch that requirement in your initial description.

How about these:

MIN Timestamp = 
VAR _USERNAME = Table1[UserName]
VAR _DATE = FORMAT(Table1[Date], "dd/mm/yyyy")
VAR _Result = 
CALCULATE(
    MIN(Table2[Timestamp]),
    Table2[User] = _USERNAME,
    FORMAT(Table2[Timestamp], "dd/mm/yyyy") = _DATE
)
Return
_Result

 

MAX Timestamp = 
VAR _USERNAME = Table1[UserName]
VAR _DATE = FORMAT(Table1[Date], "dd/mm/yyyy")
VAR _Result = 
CALCULATE(
    MAX(Table2[Timestamp]),
    Table2[User] = _USERNAME,
    FORMAT(Table2[Timestamp], "dd/mm/yyyy") = _DATE
)
Return
_Result

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.