Forum Discussion
Problems with dates in visuals
- Anonymous8 years ago
You should use a Calendar table. That normalizes the date data. The Date pulled into the Visuals is from the Calendar Table.
Connect the Calendar table to the primary Data Tables. The Data tables should not be connected to each other (most mlikely will not connect). the Calendar table is the common link in the case of using dates.
That will not clean up bad date data.
Here is the code for a Calendar Table I use (change the name in the front to your chosen name but don't use a DAX command name:
Dates_INV = GENERATE (
CALENDAR( DATE( YEAR( TODAY() ) - 3, MONTH( TODAY() ), DAY( TODAY()) ), TODAY()),
VAR startOfWeek = 2 // Where 1 is Sunday so this returns Monday as Week Start
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,
"MonthNameShort", FORMAT ( months, "mmm" ),
"MonthNameLong", FORMAT ( months, "mmmm" ),
"year", years,
"day index", dayIndex,
"week index", weekIndex,
"month index", INT( (years - nowYear ) * 12 + months - nowMonth ),
"year index", INT( years - nowYear )
)
))
Unless its somthign like the data if formatted for the wrong kind of data? YYYYMMDD instead of MMDDYY
Or, I'm assuming that is the size of your date table and you have a measure that is calcualting a non blank (non Null) result. If this is the case you can avoid this by limiting the dates either through Report, Page or Visual Filters. With Slicers to define date ranges or by using DAX in your measure to block results form dispalying.
Without more details of your data model and measures its hard to provide a specific solution. Can you dummy up some data so we get a better idea of what your trying to do?