Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
Hi,
I am having a little bit a problem when trying to figure out how to filter with DAX on my problem at hand.
We are currently having some unit models which each have a own release date written in database.
All the data before the release date we have there, is test data.
We are using a separate date field than the release date field on the graphics (not sure if valid?)
The problem is, that how can I filter the test data out for each unit model?
Let's say I have this kinda table
unit model | release date |
YYY | 17.7.2017 |
UUU | 18.7.2017 |
SSS | 19.7.2017 |
With the datatable like this
unit model | hit | date |
YYY | 1 | 14.7.2017 |
UUU | 2 | 14.7.2017 |
SSS | 5 | 14.7.2017 |
YYY | 4 | 15.7.2017 |
UUU | 5 | 15.7.2017 |
SSS | 8 | 15.7.2017 |
YYY | 1 | 16.7.2017 |
UUU | 2 | 16.7.2017 |
SSS | 4 | 16.7.2017 |
YYY | 7 | 17.7.2017 |
UUU | 8 | 17.7.2017 |
SSS | 9 | 17.7.2017 |
YYY | 4 | 18.7.2017 |
UUU | 3 | 18.7.2017 |
SSS | 1 | 18.7.2017 |
YYY | 2 | 19.7.2017 |
UUU | 1 | 19.7.2017 |
SSS | 2 | 19.7.2017 |
So we would not take the dates in notice that are before each unit models release date.
I have tried to figure this out for a while now and I do not seem to get anything done.. Any help would be appreciated! 🙂
Do I need some help table with this? Or does the DAX calculate this all itself?
Little bit lost with the dax atm, I have used before some datesbetween function but it does not seem to sit with this problem.
Cheers,
Niko
Solved! Go to Solution.
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
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,
Thanks for your sharing. If you have worked out your requirement, please kindly mark the corresponding post as an answer so that some others having similar problem can find the solution easily.
Thanks,
Yuliana Gu
User | Count |
---|---|
128 | |
108 | |
99 | |
65 | |
62 |
User | Count |
---|---|
136 | |
113 | |
102 | |
71 | |
60 |