Power Query Conditional Column Enter a Value If Statements Using Start and End Dates

Noli Mabida 1 Reputation point
2022-04-12T16:23:43.087+00:00

Hi,

I am adding a conditional column to enter a value between Week 01 - Week 10 depending on the dates in the start and end date columns. (see below)

192349-image.png

and my custom column has the the if and else statements as follows.

if [Start Date] > #date (2022,30,5) and [End Date] < #date(2022,06,04) then "Week 01" else
if [Start Date] > #date(2022,06,05) and [End Date] < #date(2022,06,11) then "Week 02" else
if [Start Date] > #date(2022,06,12) and [End Date] < #date(2022,06,18) then "Week 03" else
if [Start Date] > #date(2022,06,19) and [End Date] < #date(2022,06,25) then "Week 04" else
if [Start Date] > #date(2022,06,26) and [End Date] < #date(2022,07,02) then "Week 05" else
if [Start Date] > #date(2022,07,03) and [End Date] < #date(2022,07,09) then "Week 06" else
if [Start Date] > #date(2022,07,10) and [End Date] < #date(2022,07,16) then "Week 07" else
if [Start Date] > #date(2022,07,17) and [End Date] < #date(2022,07,23) then "Week 08" else
if [Start Date] > #date(2022,07,24) and [End Date] < #date(2022,07,30) then "Week 09" else
if [Start Date] > #date(2022,07,31) and [End Date] < #date(2022,08,06) then "Week 10" else
"none"

I did not get any syntax error but the above query returned an error.

192400-image.png

Is there something that I missed. Any help will be much appreciated.

Thank you.

Not Monitored
Not Monitored
Tag not monitored by Microsoft.
37,112 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Dave Patrick 426.3K Reputation points MVP
    2022-04-12T17:17:14.35+00:00

    Power query is not currently supported here on Q&A. The product group for Power Query actively monitors questions over at
    https://community.powerbi.com/t5/Power-Query/bd-p/power-bi-services

    --please don't forget to Accept as answer if the reply is helpful--

    0 comments No comments