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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
justlogmein
Helper III
Helper III

How to get the value from a previous row when the column is text or boolean?

I normally use the below DAX to retrieve a value from a pevious row, which works fine if the MAX value is a number. But what do I do if I am trying to get a value from a column that is a text or boolean type?

=
CALCULATE
	(
	MAX
		(
		'Sample Data'[Sample Taken]
		),
	FILTER
		(
		'Sample Data',
		'Sample Data'[Sample Date] < EARLIER
			(
			'Sample Data'[Sample Date]
			)
		&& 'Sample Data'[Unit Number] = EARLIER
			(
			'Sample Data'[Unit Number]
			)
		)
	)

 

4 REPLIES 4
tamerj1
Super User
Super User

Hi @justlogmein 

please use

=
VAR CurrentDate = 'Sample Data'[Sample Date]
VAR CurrentUnitTable =
    CALCULATETABLE (
        'Sample Data',
        ALLEXCEPT ( 'Sample Data', 'Sample Data'[Unit Number] )
    )
VAR DatesBeforeTable =
    FILTER ( CurrentUnitTable, 'Sample Data'[Sample Date] < CurrentDate )
VAR PreviousDate =
    MAXX ( DatesBeforeTable, 'Sample Data'[Sample Date] )
RETURN
    MAXX (
        FILTER ( DatesBeforeTable, 'Sample Data'[Sample Date] = PreviousDate ),
        'Sample Data'[Sample Taken]
    )

Unfortunately I get an error.

justlogmein_0-1655031174029.png

 

@justlogmein 

Please try

=
VAR CurrentDate = 'Sample Data'[Sample Date]
VAR CurrentUnitTable =
    CALCULATETABLE (
        'Sample Data',
        ALLEXCEPT ( 'Sample Data', 'Sample Data'[Unit Number] )
    )
VAR DatesBeforeTable =
    FILTER ( CurrentUnitTable, 'Sample Data'[Sample Date] < CurrentDate )
VAR PreviousDate =
    MAXX ( DatesBeforeTable, 'Sample Data'[Sample Date] )
RETURN
    SELECTCOLUMNS (
        FILTER ( DatesBeforeTable, 'Sample Data'[Sample Date] = PreviousDate ),
        "@Taken", 'Sample Data'[Sample Taken]
    )
Anonymous
Not applicable

Hi @justlogmein ,

 

Has this question been solved? If you have solved it, you can post your solution here. If any of the responses were helpful to you, please consider marking them as solutions, which will help more users find similar problems faster. If the question is not solved, please feel free to let us know. Thanks in advance!

 

Best Regards,
Gao

Community Support Team

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Users online (25)