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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
wal808
New Member

Filter virtual table to keep most recent dates by user and goal type

If I have users Jeff and Steve, and each can update there different goal types (products sold & cold calls).. I'd like a measure that iterates a virtual table and returns the most recent (max date) goal amount set (by name and goal type). See example below, and highlighted*** rows that result in the most recent goals to keep. Thank you in advance.

 

my table looks like this:

 

Name.     Goal.               Date set         Amt

jeff.          Prod sold.     1/1/2020.        10

jeff.          Prod sold.      2/3/2020.        15***

steve.       Cold calls.     2/15/2020.        6

Steve.      Product sold. 2/7/2020           9***

steve.       Cold calls.     3/12/202.          8***

1 ACCEPTED SOLUTION
Anonymous
Not applicable

// This calc column will
// assign to each row in the raw
// table the most recent
// goal amount for the Name
// and Goal. Of course,
// the columns Amt and [Recent Goal Amount]
// should be hidden and only exposed
// to the user via measures.
[Recent Goal Amount] = // calculated column
var __name = T[Name]
var __goal = T[Goal]
return
	MAXX(
		topn(1,
			filter(
				T,
				T[Name] = __name
				&&
				T[Goal] = __goal
			),
			T[Date set],
			DESC
		),
		T[Amt]
	)
	
// Once you have the column
// it's easy to create a measure
// that will return the recent goal amount.
[RGA] =
IF(
	HASONEFILTER( T[Name] ) && HASONEFILTER( T[Goal] ),
	SELECTEDVALUE( T[Recent Goal Amount]
)

Best

D

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

// This calc column will
// assign to each row in the raw
// table the most recent
// goal amount for the Name
// and Goal. Of course,
// the columns Amt and [Recent Goal Amount]
// should be hidden and only exposed
// to the user via measures.
[Recent Goal Amount] = // calculated column
var __name = T[Name]
var __goal = T[Goal]
return
	MAXX(
		topn(1,
			filter(
				T,
				T[Name] = __name
				&&
				T[Goal] = __goal
			),
			T[Date set],
			DESC
		),
		T[Amt]
	)
	
// Once you have the column
// it's easy to create a measure
// that will return the recent goal amount.
[RGA] =
IF(
	HASONEFILTER( T[Name] ) && HASONEFILTER( T[Goal] ),
	SELECTEDVALUE( T[Recent Goal Amount]
)

Best

D

harshnathani
Community Champion
Community Champion

HI @wal808 ,

 

Create 2 measure

 

 

Goal Date1 = 
MAXX(
SUMMARIZE('Table','Table'[Name],'Table'[Date Set],'Table'[Goal ],'Table'[Amt],"Goal Date", MAX('Table'[Date Set])),[Goal Date])

 

Total Amt = MAXX 
(FILTER('Table','Table'[Date Set] = [Goal Date1]),'Table'[Amt])

 

1.jpg

 

 

Regards,
Harsh Nathani

Did I answer your question? Mark my post as a solution! Appreciate with a Kudos!! (Click the Thumbs Up Button)

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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