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

Newbie struggling to return the week number for last week from a calendar table

Hi all,

 

I'm new to Power BI (from Qlik) and battling with DAX logic a little, it'll click for me eventually I'm sure.

 

All I want to do is return last week's week number from the attached calendar table.  If the relative week is -1, then return the value populated in the "Week of Year" column.  In the attached calendar the result should be 29.  I then want to use that measure to populate in a text box so it dynamically references the week of the report.

 

I think I need the filter fuction but I don't think I need an aggregation to go around it, IF only gives me the option of populating one of the measures in my calendar so I know that's not right.  I've tried the LOOKUPVALUE function but I think that's for searching values between tables (as in VLOOKUP)....

 

Any help would be appreciated. 

DateYearQuarterMonth NumMonthDay NameWeek of YearStart of MonthStartOfWeekStartOfCurrentWeekWeeksagoMonthsagoEnd of MonthDays in monthMondays in monthYear WeekIsCurrentWeekCurrentWeekDateCurrentWeekOfYearRelativeWeek
01/01/20242024Qtr 11JanMon101/01/202401/01/202422/07/202429631/01/2024315202401FALSE22/07/202430-29
08/01/20242024Qtr 11JanMon201/01/202408/01/202422/07/202428631/01/2024315202402FALSE22/07/202430-28
15/01/20242024Qtr 11JanMon301/01/202415/01/202422/07/202427631/01/2024315202403FALSE22/07/202430-27
22/01/20242024Qtr 11JanMon401/01/202422/01/202422/07/202426631/01/2024315202404FALSE22/07/202430-26
29/01/20242024Qtr 11JanMon501/01/202429/01/202422/07/202425631/01/2024315202405FALSE22/07/202430-25
05/02/20242024Qtr 12FebMon601/02/202405/02/202422/07/202424529/02/2024294202406FALSE22/07/202430-24
12/02/20242024Qtr 12FebMon701/02/202412/02/202422/07/202423529/02/2024294202407FALSE22/07/202430-23
19/02/20242024Qtr 12FebMon801/02/202419/02/202422/07/202422529/02/2024294202408FALSE22/07/202430-22
26/02/20242024Qtr 12FebMon901/02/202426/02/202422/07/202421529/02/2024294202409FALSE22/07/202430-21
04/03/20242024Qtr 13MarMon1001/03/202404/03/202422/07/202420431/03/2024314202410FALSE22/07/202430-20
11/03/20242024Qtr 13MarMon1101/03/202411/03/202422/07/202419431/03/2024314202411FALSE22/07/202430-19
18/03/20242024Qtr 13MarMon1201/03/202418/03/202422/07/202418431/03/2024314202412FALSE22/07/202430-18
25/03/20242024Qtr 13MarMon1301/03/202425/03/202422/07/202417431/03/2024314202413FALSE22/07/202430-17
01/04/20242024Qtr 24AprMon1401/04/202401/04/202422/07/202416330/04/2024305202414FALSE22/07/202430-16
08/04/20242024Qtr 24AprMon1501/04/202408/04/202422/07/202415330/04/2024305202415FALSE22/07/202430-15
1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

@LauraChou I would think maybe something like this:

 

Measure = 
  VAR __Today = TODAY()
  VAR __CurrentWeek = MINX( FILTER( ALLSELECTED( 'Table' ), [StartOfWeek] >= __Today ), [Week of Year] )
  VAR __Result = __CurrentWeek - 1
RETURN
  __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
LauraChou
Regular Visitor

That worked a charm!  Thank you!

Greg_Deckler
Community Champion
Community Champion

@LauraChou I would think maybe something like this:

 

Measure = 
  VAR __Today = TODAY()
  VAR __CurrentWeek = MINX( FILTER( ALLSELECTED( 'Table' ), [StartOfWeek] >= __Today ), [Week of Year] )
  VAR __Result = __CurrentWeek - 1
RETURN
  __Result

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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