Forum Discussion
vincentakatoh
8 years agoHelper IV
DAX: IF, Filter, Datesbetween
Hi,
Trying to add new column such that
IF datesbetween (2017,9,11), (2017,9,15)= "Proto1"
IF datesbetween (2017,9,18), (2017,9,22)= "Proto2"
IF datesbetween (2017,9,25), (2017,9,29)= "Proto3"
otherwise "null"
Can advice how can i write above in DAX? Should I be using IF or Filters?
Hi vincentakatoh,
Try the following formula:
Proto = SWITCH ( TRUE (), 'Calendar'[Date] >= DATE ( 2017, 9, 11 ) && 'Calendar'[Date] <= DATE ( 2017, 9, 15 ), "Proto1", 'Calendar'[Date] >= DATE ( 2017, 9, 18 ) && 'Calendar'[Date] <= DATE ( 2017, 9, 22 ), "Proto2", 'Calendar'[Date] >= DATE ( 2017, 9, 25 ) && 'Calendar'[Date] <= DATE ( 2017, 9, 29 ), "Proto3", BLANK () )Regards,
MFelix
2 Replies
- MFelixSuper User
Hi vincentakatoh,
Try the following formula:
Proto = SWITCH ( TRUE (), 'Calendar'[Date] >= DATE ( 2017, 9, 11 ) && 'Calendar'[Date] <= DATE ( 2017, 9, 15 ), "Proto1", 'Calendar'[Date] >= DATE ( 2017, 9, 18 ) && 'Calendar'[Date] <= DATE ( 2017, 9, 22 ), "Proto2", 'Calendar'[Date] >= DATE ( 2017, 9, 25 ) && 'Calendar'[Date] <= DATE ( 2017, 9, 29 ), "Proto3", BLANK () )Regards,
MFelix
- vincentakatohHelper IV
Works great. Thanks for introducing the "SWITCH" function. very useful function indeed.
Rgds, Vincent