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
mikemi
Frequent Visitor

DAX relative date filtering

I am looking to create two relative date measures for the same field "Gross": Last 30 Days, and Quarter-To-Date.

I created a quick measure but unsure how to filter for the two relative dates above. The end goal is to create a table that shows "Gross" created in the last 30 days, and quarter-to-date (which I don't believe can be done without two separate measures if I want to include them in the same table).

 

Below is the quick measure where I was only able to select one date. I assume the IN { DATE(2018, 4, 27) section is the chunk that needs to be replaced.

 

Gross for Friday, April 27, 2018 = 
CALCULATE(
	SUM('Opportunity'[Gross]),
	'Opportunity'[Created Date] IN { DATE(2018, 4, 27) }
)

 

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

 

Share the link from where i can download your PBI file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks, @Ashish_Mathur.

 

I have the file ready to upload but not sure how to share as a link. Suggestions?

Hi,

 

Upload the file to OneDrive/Google Drive and share the download link here.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi,

 

Try this measure

 

=CALCULATE(SUM('Opportunity'[Gross]),DATESBETWEEN(DateKey[Date],MIN(DateKey[Date])-30,MIN(DateKey[Date])))

 

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Great measure ! Works for me as well 🙂 Thanks

Thanks! That works for last 30 days. How would quarter-to-date work?

Hi,

 

Try this measure for QTD

 

=CALCULATE(SUM('Opportunity'[Gross]),DATESBETWEEN(DateKey[Date],EDATE(MIN(DateKey[Date]),-3),MIN(DateKey[Date])))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Now neither are working - both measures are the DAX you mentioned. Thoughts?

 

Last_30_Days_QTD_Measures.png

Hi,

 

Create a slicer and drag the Date column from the DateKey table.  Select any specific date there.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.