Forum Discussion
DAX problem with date filtering
- 9 years ago
Hmm... Might have the solution already to my problem:
SalesRange =
CALCULATE (
sum([hit]);
FILTER (
VALUES ( DataTable[date] );
COUNTROWS (
FILTER (
UnitsTable;
DataTable[date] >= UnitsTable[release date]
)
) > 0
)
)
Hi nisuomi
If I understand your problem correctly, you'd like to make DAX-calculations based on a date. It isn't so straight forward when you have different tables, which relate to each other. The most pragmatic (but not smooth) way to solve this (in my opinion), is to make a look up and then have your calculations in the same table. So I would do the following:
Make a column in Date Table with release dates:
Release date from Unit table = LOOKUPVALUE('Unit table'[Release date];'Unit table'[Unit model];'Date table'[Unit model])
Make a column for hits after the release date:
Hits after release = IF(AND('Date table'[Unit model]="YYY"; 'Date table'[Date] >= 'Date table'[Release date from Unit table]);'Date table'[Hit];IF(AND('Date table'[Unit model]="UUU"; 'Date table'[Date] >= 'Date table'[Release date from Unit table]);'Date table'[Hit];IF(AND('Date table'[Unit model]="SSS"; 'Date table'[Date] >= 'Date table'[Release date from Unit table]);'Date table'[Hit];0)))
This would indeed accommodate your problem, but it isn't smooth. See picture below.
Hope this makes sense. Let me know if you want me to elaborate on anything and let me know how it goes.
Best,
Martin