Forum Discussion
Measure returning column text value based on date
Hi awitt1Temp ,
Since you are now using DirectQuery, you cannot create calculated columns like your previous RelatedCoreGroup, but you can achieve the same result using a DAX measure. The idea is to use a measure that dynamically determines whether to show "Core" or "Closeout" based on the Sales Line Created Date. Here's the DAX measure that replicates your original logic:
RelatedCoreGroupMeasure =
VAR SalesLineCreated = MAX(SalesTable[Sales Line Created Date])
VAR RelatedBeforeDate = MAX('Product Grouping'[CoreGroup])
VAR RelatedAfterDate = MAX('Product Grouping'[CoreGroup2])
VAR Result =
IF (
SalesLineCreated <= DATE(2025, 3, 1),
RelatedBeforeDate,
RelatedAfterDate
)
RETURN
IF (
ISBLANK(Result),
"Other",
Result
)
You can use this measure in your visual to reflect the correct group label based on the date. However, since measures cannot be used as row groupings in matrix visuals, this approach works best if you only need to display the group label or use it in tooltips or conditional logic. If you need to use the result for grouping rows, you'll have to consider alternatives such as creating a disconnected group table or pre-aggregated calculated table, though those are more limited in DirectQuery mode. Let me know if you need help adapting the visual to support grouping with this logic.
Best regards,