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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

DAX Filter on dates

Hello noob BI user here,

 

I have a large table with a set of dates and reliated market values. I have a slicer set up which allows the user to set the time period they want to analyse the data over, i.e betweem Aug 5th 2019 to Sep 5th 2019.  

 

Given the selected start and end period that the user choose to analyse over, using the slicer. I need to create a meaure that records the market value at the start date and end date periods. Below is an example of some dates and data:

 

DateMV
22/04/201922
22/04/20193423
15/06/20192354
01/07/2019-456
14/09/201945

 

I used the following code in my measures

 

Start Date = FIRSTDATE(test[Date])  <- This works and changes as the slicer date range changes
 
First Settlement = SUMX(FILTER(test, test[Date] = [Start Date] ), test[MV])  <- Doesn't work and returns the sum of ALL of the market values (5388)
 
I used the same code premis on the following table and got the right answer...
CodeMV
A22
A3423
B2354
C-456
D45

 

First Settlement = SUMX(FILTER(test, test[Code] = "A" ), test[MV])    returns 3445

 

 

 

Help me please!

1 ACCEPTED SOLUTION
Nathaniel_C
Super User
Super User

Hi @Anonymous ,

Is this what you are looking for? I did note that one date was duplicated which I changed as I did not think we could have two market values on same date. 

 

First date = FIRSTDATE(markv[Date])
Last Date = LASTDATE(markv[Date])
Market Value First Date = CALCULATE(MAX(markv[MV]),FILTER(markv,MIN(markv[Date])=[First date]))
Market Value Last date = CALCULATE(MAX(markv[MV]),FILTER(markv,MAX(markv[Date])=[Last Date]))

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

First date last date.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Nathaniel_C
Super User
Super User

Hi @Anonymous ,

Is this what you are looking for? I did note that one date was duplicated which I changed as I did not think we could have two market values on same date. 

 

First date = FIRSTDATE(markv[Date])
Last Date = LASTDATE(markv[Date])
Market Value First Date = CALCULATE(MAX(markv[MV]),FILTER(markv,MIN(markv[Date])=[First date]))
Market Value Last date = CALCULATE(MAX(markv[MV]),FILTER(markv,MAX(markv[Date])=[Last Date]))

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

First date last date.PNG





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Anonymous
Not applicable

Thank you!!!!!!!

 

In this case you can have two market values on the same date so I use sum in place of max:

 

Market Value First Date = CALCULATE(sum(markv[MV]),FILTER(markv,MIN(markv[Date])=[First date]))

Thanks Nathaniel for your help

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors