cancel
Showing results for
Did you mean:

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

Post Patron

## IS Last 2 Years True/False DAX

Can someone help me turn this formula I have for last 2 days into last 2 years True/False answer?

IsTwoDaysAgo = if('Calendar'[DateTime12am]=TODAY()-2,"True","False")

Let me know!
1 ACCEPTED SOLUTION
Super User

@unclejemima , IsTwoDaysAgo  is correct. if you need two years date , try like

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,1,1) && [DateTime12am] <=today(),"True","False")

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,month(TODAY()),day(TODAY())) && [DateTime12am] <=today(),"True","False")

3 REPLIES 3
Super User

@unclejemima , IsTwoDaysAgo  is correct. if you need two years date , try like

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,1,1) && [DateTime12am] <=today(),"True","False")

IsTwoDaysAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,month(TODAY()),day(TODAY())) && [DateTime12am] <=today(),"True","False")

Post Patron

Thank you!!

Do both give the same result or why the different options?

I used this...

IsTwoYearsAgo = if('Calendar'[DateTime12am]>=date(year(TODAY())-2,month(TODAY()),day(TODAY())) && [DateTime12am] <=today(),"True","False")

Super User

Hi,

Try this calculated column formula

='Calendar'[DateTime12am]>=edate(today(),-24)

Hope this helps.

Regards,
Ashish Mathur
http://www.ashishmathur.com

Announcements

#### Power BI Monthly Update - November 2023

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

#### Fabric Community News unified experience

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

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