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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
sirlanceohlott
Advocate III
Advocate III

Date Table Relationship Not Working

Good afternoon, 

 

I've been at an impasse for the past hour regarding a Date Table I created within a new report. 

 

I'll share what I've attempted prior to sharing DAX & images. 

 

  • Date Table is marked as the Date Table.
  • I've made sure the Date Table and any of the tables it would be connecting to are all in the same format Date/Time through the relationship pane as well as Power Query Editor.
  • I've also verified in SSMS the field it is being joined to is Date/Time. 

 

I'm not sure if this would present an issue, but the data tables are pulled in through Direct Query. 

 

Here is the DAX I utilized to make the Date Table:

 

 

Date = 
  GENERATE (
    CALENDAR( DATE( YEAR( TODAY() ) - 2, MONTH( TODAY() ), DAY( TODAY()) ), TODAY()),
    VAR startOfWeek = 1 // Where 1 is Sunday and 7 is Saturday, thus a 3 would be Tuesday    
    VAR currentDay = [Date]
    VAR days = DAY( currentDay )
    VAR months = MONTH ( currentDay )
    VAR years = YEAR ( currentDay )
    VAR nowYear = YEAR( TODAY() )
    VAR nowMonth = MONTH( TODAY() )
    VAR dayIndex = DATEDIFF( currentDay, TODAY(), DAY) * -1
    VAR todayNum = WEEKDAY( TODAY() )
    VAR weekIndex = INT( ROUNDDOWN( ( dayIndex + -1 * IF( todayNum + startOfWeek <= 6, todayNum + startOfWeek, todayNum + startOfWeek - 7 )) / 7, 0 ) )
  RETURN ROW (
    "day", days,
    "month", months,
    "year", years,
    "day index", dayIndex,
    "week index", weekIndex,
    "month index", INT( (years - nowYear ) * 12 + months - nowMonth ),
    "year index", INT( years - nowYear )
  )
)

 

 

Here is a view from the relationship pane:

Relationship Pane ViewRelationship Pane View

 

Here is the Edit Relationship View: 

relationshipv2.PNG

 

I appreciate any help in resolving this issue!

1 ACCEPTED SOLUTION
VasTg
Memorable Member
Memorable Member

@sirlanceohlott 

 

Is there any reason why you should keep dateadded and Date columns in Date/Time datatype instead of Date(mm/dd/yyyy format)?

 

Try it and let us know.

 

If this helps, mark it as a solution.

Kudos are good too.

Connect on LinkedIn

View solution in original post

3 REPLIES 3
VasTg
Memorable Member
Memorable Member

@sirlanceohlott 

 

Is there any reason why you should keep dateadded and Date columns in Date/Time datatype instead of Date(mm/dd/yyyy format)?

 

Try it and let us know.

 

If this helps, mark it as a solution.

Kudos are good too.

Connect on LinkedIn

@VasTg, it worked like a charm, I'll leave the Date/Time variation out of the mix for the time being.

 

I appreciate your help!

@VasTg I'll shift to from Date/Time to Date and see if this resolves the issue.

 

The only reason I was keeping it in Date/Time was if I wanted to do some calculations on submission times.

 

I'll let you know how it goes!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.