cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
diskovered Member
Member

changing value dynamically

How do I change this value dynamically '20191118' on a weekly basis.

This value can be any day in the current week (Monday-Sunday) using the following date format: 20191118 (yyyymmdd)

FROM [tbl].[db].[test]
WHERE '20191118' BETWEEN [start_dt] AND [end_dt]

Doesn't matter if this can be done in SQL or PowerBI. I'm open to both. Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
EricJ Frequent Visitor
Frequent Visitor

Re: changing value dynamically

Output the first day of the current week.  Give a try!

 

Select dateadd(wk, datediff(wk, 0, getdate()), 0) as ThisWeekStart,
format(dateadd(wk, datediff(wk, 0, getdate()), 0),'yyyyMMdd')

 

 

Eric Ji | Senior Business Intelligence Consultant
www.designmind.com

View solution in original post

3 REPLIES 3
EricJ Frequent Visitor
Frequent Visitor

Re: changing value dynamically

Output the first day of the current week.  Give a try!

 

Select dateadd(wk, datediff(wk, 0, getdate()), 0) as ThisWeekStart,
format(dateadd(wk, datediff(wk, 0, getdate()), 0),'yyyyMMdd')

 

 

Eric Ji | Senior Business Intelligence Consultant
www.designmind.com

View solution in original post

venal Senior Member
Senior Member

Re: changing value dynamically

@diskovered 

what is the startdate and enddate here.

If for example 201911118 means - the entire week data or else only one particular date data..

Community Support Team
Community Support Team

Re: changing value dynamically

Hi diskovered, 

Did you mean that you want to use parameter in power bi  query, right? If so, you could try to refer to Pass parameter to SQL Queries statement using Power BI  for details. If not, please correct me and inform me more detailed information(such as your expected output).

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New Ranks and Rank Icons in 2020

New Ranks and Rank Icons in 2020

Read the announcement for more information!

New Kudos Given Badges Coming

New Kudos Given Badges Coming

We're rolling out new Kudos Given badges. Find out how many Kudos you've given.

November 2019 Community Highlights

November 2019 Community Highlights

Get an overview of the events and great community content from November.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Solution Authors
Top Kudoed Authors (Last 30 Days)