Forum Discussion
year to date
Hi,
I have a huge table with about 90,000 rows, one column contains the date starting somewhere in 2015. Each date is repeated several times which explains the number of rows.
If I put a filter on that column I get easily all dates of last year but what I need are the dates from today at last year to today. There is an option YTD but it doesn't work the way I did.
Basically: =if(date >= edate(today(),-12),"include", "ignore")
Kind regards,
JP-Ronse
Hi JP-Ronse,
To use the solution suggested by WolfBiber, you need to create a calendar table first, and create a one to many relationship between calendar table and your source table.
DateTime=CALENDAR(DATE(2015,1,1), DATE(2018,12,31))
By the way, all above functions are DAX functions which should be used in report view mode rather than Query Editor mode.
Regards,
Yuliana Gu
;) then use PowerBi Desktop, its for free
https://powerbi.microsoft.com/en-us/desktop/
and you can create date Tables in Excel 2016, don't know if in 2013 its also working
JP-Ronse You can create calendar table in PQ as well, here is link for that , I'm sure there are more.
https://www.powerquery.training/portfolio/dynamic-calendar-table/
11 Replies
- WolfBiber
Microsoft Employee
Hey,
you can calculate rolling sum with
= CALCULATE(SUM(InternetSales_USD[SalesAmount_USD]),DATESINPERIOD(DateTime[DateKey],DATE(2018,01,03),-12,month))
Please refer to https://msdn.microsoft.com/en-us/library/ee634539.aspx
Greetings
- JP-Ronse
Helper II
Hi,
Thanks for the swift reply, I have
let Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"DAY", type datetime}, {"THRESHOLD", Int64.Type}, {"MIN_OCCURENCES", Int64.Type}, {"METRIC", type text}, {"RESOURCE_NAME", type text}, {"CONT_BREACHING_COUNT", Int64.Type}, {"SEPARATED_BREACHING_COUNT", Int64.Type}, {"islast<I1>months", type any}, {"12", type any}}), #"Filtered Rows" = Table.SelectRows(#"Changed Type", each DATESINPERIOD([DAY],DATE(2018,01,03),-12,month)) in #"Filtered Rows"But it says: The name 'DATESINPERIOD' wasn't recognized.
Secondly, the todays date should be adapted automatically.
(I am a new, sorry for all the stupid questions)
I am using Excel 2013 with PQ add-in.
Kind regards,
JP
- parry2k
Super User
- v-yulgu-msft
Microsoft Employee
Hi JP-Ronse,
To use the solution suggested by WolfBiber, you need to create a calendar table first, and create a one to many relationship between calendar table and your source table.
DateTime=CALENDAR(DATE(2015,1,1), DATE(2018,12,31))
By the way, all above functions are DAX functions which should be used in report view mode rather than Query Editor mode.
Regards,
Yuliana Gu
- JP-Ronse
Helper II
Hi,
I am using PQ & Excel 2013, a calendar table is not available in my configuration.
Kind regards,
JP-Ronse
- WolfBiber
Microsoft Employee
;) then use PowerBi Desktop, its for free
https://powerbi.microsoft.com/en-us/desktop/
and you can create date Tables in Excel 2016, don't know if in 2013 its also working