cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Anonymous
Not applicable

Coding for 3 month

Hi All

 

I was wondering if you can help with below 

 

I need to write have a conditional column for 3 month prior to review date

 

So, I have "review dates" column, and  need something along the lines of "IF 3 months left before "Review Date" them then ALERT, otherwise NO ALERT"

 

Ideally to have rolling code so I don't have to alter it manually every time dates change 

 

Any help will be greatly appriciated 

1 ACCEPTED SOLUTION
Barthel
Solution Sage
Solution Sage

Hey @Anonymous,

You could add an 'Alert' calculated column to your table:

 

 

Alert = 
IF ( DATEDIFF ( TODAY (), 'Table'[Reviewdate], MONTH ) <= 3, "ALERT", "NO ALERT" )

 

 

DATEDIFF calculates the difference between two dates, in this case in months. TODAY returns today as a date. This is updated every time the report is refreshed, making the code dynamic.

Result:

ReviewdateAlert

Sunday, 1 January 2023ALERT
Wednesday, 1 February 2023ALERT
Wednesday, 1 March 2023ALERT
Saturday, 1 April 2023NO ALERT
Monday, 1 May 2023NO ALERT

View solution in original post

4 REPLIES 4
Barthel
Solution Sage
Solution Sage

Hey @Anonymous,

You could add an 'Alert' calculated column to your table:

 

 

Alert = 
IF ( DATEDIFF ( TODAY (), 'Table'[Reviewdate], MONTH ) <= 3, "ALERT", "NO ALERT" )

 

 

DATEDIFF calculates the difference between two dates, in this case in months. TODAY returns today as a date. This is updated every time the report is refreshed, making the code dynamic.

Result:

ReviewdateAlert

Sunday, 1 January 2023ALERT
Wednesday, 1 February 2023ALERT
Wednesday, 1 March 2023ALERT
Saturday, 1 April 2023NO ALERT
Monday, 1 May 2023NO ALERT
Anonymous
Not applicable

Hi Barthel

 

Thank you so much for getting back to me!

This is almost what I need it seems, but I don't need the today's date 

The ReviewDate column has the dates against which i'd like to go

 

Could you please advise on how to make it so if its 3 months before the date in ReviewDate column ALERT, otherwise NO ALERT 

the 

@Anonymous 

What would you want to compare with the review date? 3 months relative to what? Now the calculated column defines review dates which are within the next 3 months from today as 'ALERT'.

Anonymous
Not applicable

Yes you are absolutely right 

 

Apologies I have had a very long day

 

Thank you once again and apologies once again

 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors