0
votes

I am attempting to create a column with 0 or 1 column. I have got IF statement to check if today is between start date and end date.

At the moment, I want it to look at the two dates in one table and assign 1 if today is between start and end dates and 0 if not.

I tried below with no luck

Column = IF(AWBPS[START_DTTM] >= today(),1,IF(AWBPS[END_DTTM] <= today (), 0))

or

Column = DATESBETWEEN(today(), AWBPS[START_DTTM],AWBPS[END_DTTM])
2

2 Answers

0
votes

If you want to have a column with 0 or 1 then it would be the best if you apply your expression in the query editor. So go to Edit Query > Add Column > Custom Column and enter the following expression:

= if AWBPS[START_DTTM] >= DateTime.Date(DateTime.LocalNow()) and 
     AWBPS[END_DTTM]   <= DateTime.Date(DateTime.LocalNow()) 
  then 1 
  else 0
0
votes

You can combine conditions in DAX using the && AND operator.

Column =
IF ( AWBPS[START_DTTM] >= TODAY () && AWBPS[END_DTTM] <= TODAY (), 1, 0 )