Forum Discussion
DAX Month Date Table
- 3 years ago
Hi spandy34
please try
Month Date =
VAR MinDate =
DATE ( 2007, 7, 1 )
VAR MaxDate =
DATE ( 2099, 12, 31 )
VAR Months =
DATEDIFF ( MinDate, MaxDate, MONTH )
VAR T1 =
GENERATESERIES ( 0, Months, 1 )
RETURN
SELECTCOLUMNS (
T,
"StartDate", EDATE ( Mindate, [Value] ),
"EndDate", EOMONTH ( MinDate, [Value] )
) - 3 years ago
Sorry its a typo in the variable name
Month Date =
VAR MinDate =
DATE ( 2007, 7, 1 )
VAR MaxDate =
DATE ( 2099, 12, 31 )
VAR Months =
DATEDIFF ( MinDate, MaxDate, MONTH )
VAR T =
GENERATESERIES ( 0, Months, 1 )
RETURN
SELECTCOLUMNS (
T,
"StartDate", EDATE ( Mindate, [Value] ),
"EndDate", EOMONTH ( MinDate, [Value] )
) - Anonymous3 years ago
Hi spandy34 ,
Here are the steps you can follow:
1. Create calculated table.
Table = var _table1= CALENDAR( DATE(2007,1,1), DATE(2099,12,31)) var _table2= ADDCOLUMNS( _table1,"Enddate",EOMONTH([Date],0)) return FILTER( _table2, [Date]=MINX(FILTER(_table2,YEAR([Date])=YEAR(EARLIER([Date]))&&MONTH([Date])=MONTH(EARLIER([Date]))),[Date]))2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
- 3 years ago
spandy34
Please refer to attached sample file with the solutionMonth Date = VAR MinDate = DATE ( 2007, 7, 1 ) VAR MaxDate = DATE ( 2099, 12, 31 ) VAR Months = DATEDIFF ( MinDate, MaxDate, MONTH ) VAR T = GENERATESERIES ( 0, Months, 1 ) RETURN SELECTCOLUMNS ( T, "StartDate", EDATE ( Mindate, [Value] ), "EndDate", EOMONTH ( MinDate, [Value] ) )
Hi spandy34 ,
Here are the steps you can follow:
1. Create calculated table.
Table =
var _table1=
CALENDAR(
DATE(2007,1,1),
DATE(2099,12,31))
var _table2=
ADDCOLUMNS(
_table1,"Enddate",EOMONTH([Date],0))
return
FILTER(
_table2, [Date]=MINX(FILTER(_table2,YEAR([Date])=YEAR(EARLIER([Date]))&&MONTH([Date])=MONTH(EARLIER([Date]))),[Date]))
2. Result:
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly
Hi Anonymous
That would definitely work. But why to create a 35k rows calendar table then iterate over it two times, first time to add a 35k rows column and 2nd time to filter it down 1k rows, while the same can be achieved in one iteration over a 1k rows series table which is 315 times faster?