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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.