Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Santosh19
Frequent Visitor

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

1 ACCEPTED SOLUTION
Anonymous
Not 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.

 

View solution in original post

3 REPLIES 3
Anonymous
Not 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.

 

v-angzheng-msft
Community Support
Community 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.

AlexisOlson
Super User
Super 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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.