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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ggzmorsh
Helper II
Helper II

Calculate Max to Return Text

I have Table1 which contains 4 ID occurrences in 4 different dates/times and 4 different remarks. What i wanted to do is to return the last occurring remark from the last date or most recent.

 

I tried using a simple MAX value to return the last remark however it is only returning me an alphabetically order result which is "D". I wanted to return "B" however lookup value does not work for me because the date/time has a duplicate(A,B). 

 

 

 

IDDateRemarks
123ABC01/01/2020 09:22:00D
123ABC01/01/2020 09:22:23C
123ABC01/01/2020 10:15:47A
123ABC01/01/2020 10:15:47B
1 ACCEPTED SOLUTION

Hi @ggzmorsh ,

 

You could first create an index column,then create a measure as below:

Measure = 
var _maxdate=CALCULATE(MAX('Table'[Date]),ALL('Table'))
VAR _index=CALCULATE(MAX('Table'[Index]),FILTER(ALL('Table'),'Table'[Date]=_maxdate))
Return
CALCULATE(MAX('Table'[Remarks]),FILTER('Table','Table'[Index]=_index))

Or if you need a calculated column,you could use below dax expression:

Column = 
var _maxdate=CALCULATE(MAX('Table'[Date]),ALL('Table'))
var _index=CALCULATE(MAX('Table'[Index]),FILTER('Table','Table'[Date]=_maxdate))
Return
CALCULATE(MAX('Table'[Remarks]),FILTER('Table','Table'[Index]=_index))

And you will see:

v-kelly-msft_0-1610326090120.png

v-kelly-msft_1-1610326101513.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

View solution in original post

4 REPLIES 4
littlemojopuppy
Community Champion
Community Champion

Hi @ggzmorsh.  Try this...

Most Recent Remark:=
	VAR	MostRecentRemarkDateTime =
		CALCULATE(
			LASTNONBLANK(
				Remarks[DateTime],
				TRUE()
			),
			ALLEXCEPT(
				Remarks,
				Remarks[ID]
			)
		)
	RETURN
	
	LOOKUPVALUE(
		Remarks[Remarks],
		Remarks[DateTime],
		MostRecentRemarkDateTime,
		Remarks[ID],
		SELECTEDVALUE(Remarks[ID])
	)

Strange my post got duplicated. I will link the correct post.
Calculate MAX text value - Microsoft Power BI Community


I have tried the formula you gave me and to let you know it does not work as it only returns an error A table of multiple values was supplied where a single value was expected.. I forgot to mention that Table1 where it contains all the entries with duplicates i have created a dax table Table2 which contains distinct of ID from Table1 and from there to get the current remark.

Hi @ggzmorsh ,

 

You could first create an index column,then create a measure as below:

Measure = 
var _maxdate=CALCULATE(MAX('Table'[Date]),ALL('Table'))
VAR _index=CALCULATE(MAX('Table'[Index]),FILTER(ALL('Table'),'Table'[Date]=_maxdate))
Return
CALCULATE(MAX('Table'[Remarks]),FILTER('Table','Table'[Index]=_index))

Or if you need a calculated column,you could use below dax expression:

Column = 
var _maxdate=CALCULATE(MAX('Table'[Date]),ALL('Table'))
var _index=CALCULATE(MAX('Table'[Index]),FILTER('Table','Table'[Date]=_maxdate))
Return
CALCULATE(MAX('Table'[Remarks]),FILTER('Table','Table'[Index]=_index))

And you will see:

v-kelly-msft_0-1610326090120.png

v-kelly-msft_1-1610326101513.png

 

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

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

That is weird!  I looked at the solutions in the other post...I'd go with one of those.

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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.

Top Solution Authors