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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

Dynamic card to show previous week and date range

Hello,

 

I have a calendar table connected to my data table and i want to have a card visualization which shows the previous week number, the year associated with that week number and the range of dates, such as:

Week #10 2022

7 - 13 March

 

Here is my attempt but i am not sure how to proceed since i want to link back to my calendar table to get the correct week number and corresponding date range:

 

 

Label with Line Breaks = 
VAR Label =
    "Week #" & [PreviousWeekNumber]
        & UNICHAR ( 10 ) & YEAR(TODAY())
    "Dates: " & SelectedDateRange
        & UNICHAR ( 10 ) & SelectedItem
RETURN
    Label

 

 

 

Any help is much appreciated!

1 ACCEPTED SOLUTION
davehus
Memorable Member
Memorable Member

Hi @Anonymous ,

 

Could you try something like this maybe? Using PowerQuery get the the start date for the previous week

Powerquery measure

DateLastWeek = Date.AddDays(Date.StartOfWeek([DateKey]),-7)

Then use Add Column to get the Week, Year, Week Start/End etc from this column.

DatePriorWeek = "Week #"&Text.From([Week of Year])&" "&Text.From([Year])&" "&Text.Start(Text.From([Start of Week]),2)&" - "&Text.Start(Text.From([End of Week]),2)& " " &Text.From([Month Name])

Delete the Add Columns except the custom measure.

Finally Create A Dax Measure 

Measure = CALCULATE( MAX(DateTable[DatePriorWeek]), FILTER(DateTable,DateTable[DateKey]=MAX(DateTable[DateKey])))

To get below:
 
davehus_0-1647817220861.png

 

 

View solution in original post

1 REPLY 1
davehus
Memorable Member
Memorable Member

Hi @Anonymous ,

 

Could you try something like this maybe? Using PowerQuery get the the start date for the previous week

Powerquery measure

DateLastWeek = Date.AddDays(Date.StartOfWeek([DateKey]),-7)

Then use Add Column to get the Week, Year, Week Start/End etc from this column.

DatePriorWeek = "Week #"&Text.From([Week of Year])&" "&Text.From([Year])&" "&Text.Start(Text.From([Start of Week]),2)&" - "&Text.Start(Text.From([End of Week]),2)& " " &Text.From([Month Name])

Delete the Add Columns except the custom measure.

Finally Create A Dax Measure 

Measure = CALCULATE( MAX(DateTable[DatePriorWeek]), FILTER(DateTable,DateTable[DateKey]=MAX(DateTable[DateKey])))

To get below:
 
davehus_0-1647817220861.png

 

 

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.

Top Solution Authors