Forum Discussion
Value between Two Dates
Hi Creative_tree88 ,
To adapt the DAX formula to dynamically use the month of Sales Letter B Date (or default to the same month as Sales Letter A Date if Sales Letter B Date is blank), you can modify the calculation of _end to ensure it always picks up the correct month.
Updade DAX:
Value Between Two Dates Lookup =
VAR _start = 'Finance Data'[Sales Letter A Date]
VAR _end =
IF(
ISBLANK('Finance Data'[Sales Letter B Date]),
DATE(YEAR(_start), MONTH(_start), DAY(EOMONTH(_start, 0))),
DATE(YEAR('Finance Data'[Sales Letter B Date]), MONTH('Finance Data'[Sales Letter B Date]), DAY(EOMONTH('Finance Data'[Sales Letter B Date], 0)))
)
VAR _key = 'Finance Data'[KEY]
VAR _codesInRange =
FILTER(
'Sales Data',
'Sales Data'[Sales Date] >= _start &&
'Sales Data'[Sales Date] <= _end &&
'Sales Data'[KEY] = _key
)
VAR _result =
CONCATENATEX(
_codesInRange,
'Sales Data'[Code],
", "
)
RETURN
IF(
ISBLANK(_result),
BLANK(),
_result
)
if Sales Letter B Date is blank the end date is set to the last day of the month of Sales Letter A Date using EOMONTH(_start, 0).
If Sales Letter B Date is not blank it uses the last day of the month of Sales Letter B Date using EOMONTH('Finance Data'[Sales Letter B Date], 0).
Bibiano_Geraldo Huge thanks for this. Really working nicely. Just quick quesiton, the output can often result in a number of examinations, separated by comma, on one line. Is there any way of separating each of these, on to a separate row? So, if there is a multiple set of results, separated by comma, it gets put onto a separate line? Thanks so much.