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 Expression for date minus 6 months

Hello,

 

I am trying to display the Vendor that is about to expire 6 months from today.

For example,

Start DateEnd DateDate of Renewal
Jan. 1, 2021Dec. 30, 2021July 1, 2021

 

I want to show from another table the Date of Renewal. I do have the formula from excel ( =EDATE(E3,-6) ) but I don't know how to convert it into a DAX expression. I've created one but it's not working.

 

Dax.PNG

 

Please I need your help. Thank you.

 

 

 

 
1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Download your PBIX file here

 

Based on the data in your PBIX you have Service Providers that have already expired and some that are expiring in the next 6 months.

 

Using this measure you can see from a table the status of each vendor

Renewal = 

VAR _DateDiff = DATEDIFF(TODAY(), SELECTEDVALUE('Vendor Data'[END]), MONTH)

RETURN

SWITCH(
    
    TRUE(),
    
    _DateDiff < 0 , "Expired",
    
    _DateDiff < 6 , "Expiring",

    "OK"
)

expire.png

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

9 REPLIES 9
PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Download your PBIX file here

 

Based on the data in your PBIX you have Service Providers that have already expired and some that are expiring in the next 6 months.

 

Using this measure you can see from a table the status of each vendor

Renewal = 

VAR _DateDiff = DATEDIFF(TODAY(), SELECTEDVALUE('Vendor Data'[END]), MONTH)

RETURN

SWITCH(
    
    TRUE(),
    
    _DateDiff < 0 , "Expired",
    
    _DateDiff < 6 , "Expiring",

    "OK"
)

expire.png

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Thank you @PhilipTreacy , your measure helped a lot. I'll use and study it. Again thank you so much.

PhilipTreacy
Super User
Super User

@Anonymous 

OK so are you trying to highlght every vendor that will expire within 6 months?

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Yes, that's right. I am trying to return all vendors who are expiring.

 

Thank you.

PhilipTreacy
Super User
Super User

Hi @Anonymous 

The 'Vendor Data'[END] column needs to be type Date.

You can see in your screenshot that it isn't.

dated.png

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Tahreem24
Super User
Super User

@Anonymous ,

From you screen shot, Vendor Date column should be of Date format. Try to make this column to Date Type like below Screen shot:

Select the Vendor Date then do the below formatting.

Capture.PNG

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

Hello @Tahreem24 ,

 

Thank you so much for this, I did what you told me to convert the text into a Date data type but unfortunately it returns the same error.

PhilipTreacy
Super User
Super User

Hi @Anonymous 

You haven't set your start date and end date columns to data type Date.

In Data view select the column(s) then change the Data type from the Ribbon

datety.png

 

Are you trying to return just a single vendor or all vendors who are expiring?

Can you please share your PBIX file, or at least copy/paste some sampledata, so I understand the structure of your data.

 

Regards

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Hello @PhilipTreacy ,

 

Thank you so much for this, I did convert it into a Date data type but it still has the same error.

 

Here's the pbix file

 

https://drive.google.com/file/d/10ZzzViZY3txGd1cqj1YOo2uVTxq3k6Bb/view?usp=drivesdk 

 

im sorry i dont know how to attached a pbix file here directly 

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.