Forum Discussion
Generateseries with Dates
- 2 years ago
That worked! I only had to add Datevalue() to my date dim column, see below. Thanks so much!
Column Flag For Rolling prev 3 Quarters and current QTD =var q = QUARTER(EDATE(TODAY(),-9))var y = YEAR(EDATE(TODAY(),-9))return if(DATEVALUE([CAL_DATE_YR_MTH_DAY_E]) >= DATE(y,q*3-2,1) && DATEVALUE([CAL_DATE_YR_MTH_DAY_E])<= TODAY(),1,0)
if([CAL_DATE_YR_MTH_DAY_E] in GENERATESERIES(EDATE(TODAY(),-9)+1,TODAY()),1,0)
or, simpler
if([CAL_DATE_YR_MTH_DAY_E]>EDATE(TODAY(),-9),1,0)
This could work but theres a conflict between datatypes, date and text. Can I convert one here in the calucation?
- lbendlin2 years agoSuper User
Pick the date column from your calendar table, or use DATEVALUE()
- mcguija2 years agoHelper III
ok, so using this:
Rolling 3 Quarters = if(DATEVALUE(Date_Dim[CAL_DATE_YR_MTH_DAY_E]) in GENERATESERIES(EDATE(TODAY(),-9)+1,TODAY()),1,0)But it brings data back but its from 2023-04-12 --> 2024-01-11 aka today.I need 2023-04-01 (3 quarters back) --> 2024-01-11 aka today. - lbendlin2 years agoSuper User
You need previous three quarters and current quarter to date?
- mcguija2 years agoHelper III
Yes, that's correct.
- lbendlin2 years agoSuper User
Rolling prev 3 Quarters and current QTD = var q = QUARTER(EDATE(TODAY(),-9)) var y = YEAR(EDATE(TODAY(),-9)) return GENERATESERIES(DATE(y,q*3-2,1),TODAY()) - mcguija2 years agoHelper III
Hi, I think we are super close, now an error is thrown, I added your column and also broke it down to see variable values, see error below.
"a table of multiple values was supplied where a single value was expected"
- lbendlin2 years agoSuper User
Please be more precise in your requirement.
Column Flag For Rolling prev 3 Quarters and current QTD = var q = QUARTER(EDATE(TODAY(),-9)) var y = YEAR(EDATE(TODAY(),-9)) return if((Date_Dim[CAL_DATE_YR_MTH_DAY_E]) >= DATE(y,q*3-2,1),1,0) - mcguija2 years agoHelper III
Hi, sadly this doesn't work either, it shows the correct start date of 2023-04-01 but the end date is way into the future - in fact all the was to the end of our date dim, where it should stop at todays date, 2024-01-12.
- lbendlin2 years agoSuper User
.
Column Flag For Rolling prev 3 Quarters and current QTD = var q = QUARTER(EDATE(TODAY(),-9)) var y = YEAR(EDATE(TODAY(),-9)) return if([CAL_DATE_YR_MTH_DAY_E]) >= DATE(y,q*3-2,1) && [CAL_DATE_YR_MTH_DAY_E]<= TODAY(),1,0) - mcguija2 years agoHelper III
hmm, something is missing, throwing errors.
- lbendlin2 years agoSuper User
Column Flag For Rolling prev 3 Quarters and current QTD = var q = QUARTER(EDATE(TODAY(),-9)) var y = YEAR(EDATE(TODAY(),-9)) return if([CAL_DATE_YR_MTH_DAY_E] >= DATE(y,q*3-2,1) && [CAL_DATE_YR_MTH_DAY_E]<= TODAY(),1,0) - mcguija2 years agoHelper III
That worked! I only had to add Datevalue() to my date dim column, see below. Thanks so much!
Column Flag For Rolling prev 3 Quarters and current QTD =var q = QUARTER(EDATE(TODAY(),-9))var y = YEAR(EDATE(TODAY(),-9))return if(DATEVALUE([CAL_DATE_YR_MTH_DAY_E]) >= DATE(y,q*3-2,1) && DATEVALUE([CAL_DATE_YR_MTH_DAY_E])<= TODAY(),1,0)