Forum Discussion
DAX Month Date Table
- 2 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] )
) - 2 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] )
) - Anonymous2 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
- 2 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 tamerj1 ,
Sorry, this was an oversight on my part, I didn't think about performance, this does cause the compute table to be iterated twice, resulting in a waste of resources.
Thanks for the heads up, I'm glad you made a correction to my problem, I'll pay more attention to this area in the future.
Best Regards,
Liu Yang
If this post helps, then please consider Accept it as the solution to help the other members find it more