Forum Discussion
How to dynamically change the datasource based on the date condition
Hi,
I Have a requirement, to point to Source 1 for Jan and Feb of every year, rest of the year to source 2, I have tried to use the date.is in month function but we can only pass one at a time, we can't make dynamic
Thanks
Kumar
- Anonymous4 years ago
Hi, Santosh19
In Power Query:Source = if Date.Month(DateTime.FixedLocalNow())<3 then Excel.CurrentWorkbook(){[Name="Table1"]}[Content]
else Excel.CurrentWorkbook(){[Name="Table2"]}[Content]----------------
Where Excel.CurrentWorkbook(){[Name="Table1"]}[Content] would be your Source1 and Excel.CurrentWorkbook(){[Name="Table2"]}[Content] would be your Source2. The condition Date.Month(DateTime.FixedLocalNow())<3 evaluates the number of month.
3 Replies
- AlexisOlsonSuper User
Not an answer to your exact question but an alternative approach.
- Load both sources.
- Filter Source 1 for Jan/Feb
- Filter Source 2 for not Jan/Feb
- Append the sources to have one combined source
- v-angzheng-msftCommunity Support
Hi, Santosh19
May I ask if your problem has been solved? Is the above post helpful to you?
If it does, could you please mark the post which help as Answered? It will help the others in the community find the solution easily if they face the same problem with you. Thank you.
- AnonymousNot applicable
Hi, Santosh19
In Power Query:Source = if Date.Month(DateTime.FixedLocalNow())<3 then Excel.CurrentWorkbook(){[Name="Table1"]}[Content]
else Excel.CurrentWorkbook(){[Name="Table2"]}[Content]----------------
Where Excel.CurrentWorkbook(){[Name="Table1"]}[Content] would be your Source1 and Excel.CurrentWorkbook(){[Name="Table2"]}[Content] would be your Source2. The condition Date.Month(DateTime.FixedLocalNow())<3 evaluates the number of month.