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
jgdgsf2
Frequent Visitor

Return value from custom calendar if date is between two dates

Hi all,

 

I have an issue that I'm sure is very simple to solve but so far haven't been able to crack!

 

Firstly, I have a custom calendar table that looks like this:

 

WeekNumberWeekEndsOnYearWeekYearPreviousWeek
108-Aug-20202001/202001-Aug-20
215-Aug-20202002/202008-Aug-20
322-Aug-20202003/202015-Aug-20
429-Aug-20202004/202022-Aug-20

 

And so on and so on for the full 52 weeks.

 

I have a separate data set like the below:

 

IDCompletion timeEmailNameEmployee NameLocationWeekYear
5329/09/2021 10:47anonymous    
29203/03/2022 15:14anonymous    
11205/11/2021 13:57anonymous    
12512/11/2021 09:01anonymous    

 

All I want to do is get the WeekYear from my custom Calendar table based on the Completion Time column - if it falls between xx-xx-xxxx and xx-xx-xxxx then the WeekYear is xx/xxxx.

 

Is there an easy way of achieving this? Thanks in advance!

1 ACCEPTED SOLUTION
speedramps
Super User
Super User

HI jgdgsf2

 

It is really easy, you just need to have the same key on both tables

eg date to date

or week to week 

not date to week !

 

Option1 (date  to date) - best option !

Create a proper calendar table with arceord for every date (eg 01/01/2020 to 31/12/2023) with

  • date
  • week ending date
  • year
  • week/year
  • previous week

 

Then create a 1:M relationship form calandar[date] to facttable[competion date].

You can now get the weekyear

 

watch this video ... 

https://www.youtube.com/watch?v=BtYn1hfdSAM

 

 

 

Option 2 (week to week)  :-

In Power Query add an extra colum to your fact table 

Date.EndOfWeek([completion date], day of week number)

 

you can then build a relation and get your WeekYear

 

 

Please click thumbs up and Accept as Solution

View solution in original post

2 REPLIES 2
speedramps
Super User
Super User

HI jgdgsf2

 

It is really easy, you just need to have the same key on both tables

eg date to date

or week to week 

not date to week !

 

Option1 (date  to date) - best option !

Create a proper calendar table with arceord for every date (eg 01/01/2020 to 31/12/2023) with

  • date
  • week ending date
  • year
  • week/year
  • previous week

 

Then create a 1:M relationship form calandar[date] to facttable[competion date].

You can now get the weekyear

 

watch this video ... 

https://www.youtube.com/watch?v=BtYn1hfdSAM

 

 

 

Option 2 (week to week)  :-

In Power Query add an extra colum to your fact table 

Date.EndOfWeek([completion date], day of week number)

 

you can then build a relation and get your WeekYear

 

 

Please click thumbs up and Accept as Solution

Hi speedramps,

 

Thank you very much - all sorted and working with the first solution you offered!

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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