cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Kevthebandit Regular Visitor
Regular Visitor

Advanced Editor - Date Table Dynamically Setting Start and End Dates based on fact table date field

This is what I have hard coded in Query Editor currently for my start and end dates, and I would like to base them off of fact table min and max dates.

 

StartDate = #date(2012, 1, 1),
EndDate = Date.From(DateTime.LocalNow()) ,

 

Thank you for your help

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Advanced Editor - Date Table Dynamically Setting Start and End Dates based on fact table date fi

Power Query:

 

= #table(type table[Date = date],List.Zip({List.Dates(List.Min(Fact[Date]),1+Duration.Days(List.Max(Fact[Date]) - List.Min(Fact[Date])),#duration(1,0,0,0))}))
Specializing in Power Query Formula Language (M)
4 REPLIES 4
blopez11 Established Member
Established Member

Re: Advanced Editor - Date Table Dynamically Setting Start and End Dates based on fact table date fi

I create my date tables using DAX

In the modeling tab, select New Table, then enter the DAX similar to the below

 

DateTable =
ADDCOLUMNS (
CALENDAR (MINX('FactTable',[Transaction Date]), MAXX('FactTable',[Transaction Date])),
"Year", YEAR ( [Date] ),
"QuarterOfYear", FORMAT ( [Date], "Q" ),
"MonthOfYear", FORMAT ( [Date], "MM" ),
"DateInt", FORMAT ( [Date], "YYYYMMDD" ),
"MonthName", FORMAT ( [Date], "mmmm" ),
"MonthInCalendar", FORMAT ( [Date], "mmm YYYY" ),
"QuarterInCalendar", "Q" & FORMAT ( [Date], "Q" ) & " " & FORMAT ( [Date], "YYYY" ),
"DayInWeek", WEEKDAY ( [Date] ),
"DayOfWeekName", FORMAT ( [Date], "dddd" ),
"DayOfWeekShort", FORMAT ( [Date], "ddd" ),
"YearMonthShort", FORMAT ( [Date], "YYYY/mmm" ),
"YearMonthSort", FORMAT ( [Date], "YYYYMM" ),
"Month", FORMAT ( [Date], "mmm" ))

Super User
Super User

Re: Advanced Editor - Date Table Dynamically Setting Start and End Dates based on fact table date fi

Power Query:

 

= #table(type table[Date = date],List.Zip({List.Dates(List.Min(Fact[Date]),1+Duration.Days(List.Max(Fact[Date]) - List.Min(Fact[Date])),#duration(1,0,0,0))}))
Specializing in Power Query Formula Language (M)
Kevthebandit Regular Visitor
Regular Visitor

Re: Advanced Editor - Date Table Dynamically Setting Start and End Dates based on fact table date fi

Thank You!

 

Kevthebandit Regular Visitor
Regular Visitor

Re: Advanced Editor - Date Table Dynamically Setting Start and End Dates based on fact table date fi

When I have more time, I could work on converting the rest of my Date Fields to DAX so I could use your logic. It is more straight forward than using Power Query. Thanks. Date Table Fields.PNG