Forum Discussion
Restrict records to current year
Hi,
I am creating a dataflow from spread sheet in sharepoint using webapi connector.
4 Replies
- collinsgSolution Sage
Hi John,
Adding this line of M code will filter for records in the current year.
= Table.SelectRows(#"Previous Step", each Date.IsInCurrentYear([Date]))
- For "Previous Step" substitute the name of your previous step.
- For [Date] substitute the name of your date column.
To add a line of M code, select the step after which you want to filter and press "fx" beside the formula bar.
Hope this helps.
- johnpjustusHelper IV
Thank you so much and it worked when I followed the steps you outlined.
So I believe in doing so whenever the dataflow is scgeduled to run, it sends only the current year query to source correct?
Thanks,
John
- collinsgSolution Sage
Hello John,
I will have to be careful with my answer because when you say "sends only...query to source" the precise answer, in general, depends on whether query folding occurs. However the precise answer may not matter to you if you're only interested in the "bottom line" result - i.e. will the query return records for the current year...the answer is "yes".
To go back to the precise answer, some sources, such as SqlServer can carry out filtering before returning a result. If this is the case Power Query will delegate filtering to the source and send a query to the source asking it to return filtered results.If a source cannot carry out filtering (e.g. an Excel file), Power Query will fetch and scan the source line by line to do the filtering. In this case the query is not "sent" but the result is still filtered.
You can read more about query folding here.
Hope this helps.