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
knajar
Regular Visitor

Filter for largest week for the most recent Year

Hello,

 

I am trying to create a measure which I can use to filer to create a table that only includes rows for the latest(largest) week for the most recent year. 

For example, the correct output below should be the first three rows having latest week column as 1 and the rest as 0.

 

knajar_2-1645888891185.png

 

 

The calculated column is what outputs using the following code:

 

Latest Week =
VAR LatestYR =
CALCULATE ( MAX ( 'Weekly Estimating Lead-Time Report'[Year] ), ALL ( 'Weekly Estimating Lead-Time Report') )
VAR LatestWK =
CALCULATE ( MAX ( 'Weekly Estimating Lead-Time Report'[Week No.] ), FILTER('Weekly Estimating Lead-Time Report','Weekly Estimating Lead-Time Report'[Year]=LatestYR))

RETURN
IF ( MIN('Weekly Estimating Lead-Time Report'[Week No.])= LatestWK , 1, 0 )

 

Thank you very much for your help.


1 ACCEPTED SOLUTION

7 REPLIES 7
Whitewater100
Solution Sage
Solution Sage

Hi:

The other members are giving you a table for the records for the latest week. What are you missing?

The measure for latest week could be
Latest Week = 
var WeekNo = SELECTEDVALUE(Dates[Week No])
 return
IF(WeekNo =MAX(Dates[Week No], 1, "-")
 

This is another table function to give you the same type of table:

Calc Tble = CALCULATETABLE('YourTable',
Dates[Year]= MAX(Dates[Year]) &&
Dates[Week of Year] = MAX(Dates[Week No.])
 
The measure for latest week could be
Latest Week = 
var WeekNo = SELECTEDVALUE(Dates[Week No])
 return
IF(WeekNo =MAX(Dates[Week No], 1, "-")
 

@Whitewater100 right???  I provided the DAX and a screen snip showing exactly the intended outcome...

littlemojopuppy
Community Champion
Community Champion

Hi @knajar 

 

This will create a table that contains the only the records for the top week in the most recent year

 

Calculated Table = 
VAR	MostRecentYear =
	CALCULATE(
		MAX(RawData[Year]),
		ALL(RawData)
	)
VAR	LargestWeek =
	TOPN(
		1,
		FILTER(
			ALL(RawData),
			RawData[Year] = MostRecentYear
		),
		RawData[WeekNumber],
		DESC
	)
RETURN

LargestWeek

 

littlemojopuppy_0-1645980216098.png

 

Hope this helps!

Hello,

 

Thank you for the reply. When I tried this solution I get the following error:

"The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."

@knajar how's this look?

Thank you very much for the response. It worked.

@knajar glad I could help!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.