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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ropathak
Microsoft Employee
Microsoft Employee

Populate column for all rows that meet condition in one row

New to DAX. Whenever UserType='New', I need to flag all rows for that userID that have a Timestamp within 10 hours of the original Timestamp when the User was 'New'. If the Timestamp goes beyond 10 hours from the last TS the user was still new, flag those rows as "Returning". 

 

UserIDTimestampUserTypeUserIdentity (DESIRED COLUMN)
A2019-03-02 03:20:00NewNew
A2019-03-02 05:20:15ReturningNew
A2019-03-015 05:24:09ReturningReturning
B2020-01-13 09:34:09NewNew
B2020-04-01 12:09:34NewNew
1 REPLY 1
camargos88
Community Champion
Community Champion

Hi @ropathak ,

 

Try this code:

 

Column =
VAR _userID = 'Table (2)'[UserID]
VAR _min = CALCULATE(MIN('Table (2)'[Timestamp]); FILTER(ALL('Table (2)'); 'Table (2)'[UserID] = _userID && 'Table (2)'[UserType] = "New"))
VAR _date = 'Table (2)'[Timestamp]

RETURN IF(DATEDIFF(_min; _date; HOUR) <= 10; "New";

IF(DATEDIFF(CALCULATE(MAX('Table (2)'[Timestamp]); FILTER(ALL('Table (2)'); 'Table (2)'[UserID] = _userID && 'Table (2)'[UserType] = "New")); 'Table (2)'[Timestamp]; HOUR) > 10; "Returning"; "New"))
 
Ricardo


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.