Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
nisuomi
Resolver I
Resolver I

DAX problem with date filtering

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 modelrelease date
YYY17.7.2017
UUU18.7.2017
SSS19.7.2017

 

 

With the datatable like this

unit modelhitdate
YYY114.7.2017
UUU214.7.2017
SSS514.7.2017
YYY415.7.2017
UUU515.7.2017
SSS815.7.2017
YYY116.7.2017
UUU216.7.2017
SSS416.7.2017
YYY717.7.2017
UUU817.7.2017
SSS917.7.2017
YYY418.7.2017
UUU318.7.2017
SSS118.7.2017
YYY219.7.2017
UUU119.7.2017
SSS219.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

1 ACCEPTED SOLUTION
nisuomi
Resolver I
Resolver I

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
)
)

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

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

 

Hits after release.png

nisuomi
Resolver I
Resolver I

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

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.