DAX calculate current status based on 2 date columns

serky

New Member
Joined
Jun 30, 2014
Messages
39
Hi
I have a data set with 2 date columns (start and end). For each record I need to determine if TODAY is before the period, during the period or after the period. My formula works OK if I'm testing TODAY in either start date or end date but I don't know how to test them together.

My current formula is:

Status:= if(countrows(values(Table[start_date]))=1,
if(values(Table[start_date])<today, "obsolete","ok"),
0)

Do I create a 'nested if' and also test Table[end_date] for 1 value, then incorporate [start_date] and [end_date] into my 'if' statement?

Or is there a better way to do this? (I am intending to use SWITCH to improve the readability).

Thanks</today,>
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
yes you will want a nested IF statement.

If today is before start date then:
True = Before
False = If today is after end date then:
True = After
False = During

Hope that helps.
 
Upvote 0
Hi @spiralrain

thanks for the feedback. I just realised my original formula was incomplete so here it is:

Status:= if(countrows(values(Table[start_date]))=1,
if(values(Table[start_date])>TODAY(), "Before","TBD"),
"")

This isn't what I was asking though (sorry if I wasn't clear) - I was more concerned about whether I have to do a test for the existence of [end date] as well as [start_date] ie - if(countrows(values(Table[start_date]))=1 AND if(countrows(values(Table[end_date]))=1

I just find it bizarre in DAX that we have to test for certain parameters before a calculation will work (unlike Excel where you just get an error; it's not like we test if a cell is a number before adding, for example).

Thanks
 
Upvote 0

Forum statistics

Threads
1,223,891
Messages
6,175,229
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top