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

IF Month equals Now

Hi

 

Was trying to work out a basic if on if month is now, but I think because I am trying to use a calculated column this is now working, is there a way to do it using a calculated column?

 

My Calculated column is:

Planned Defleet = Vehicles[for_disposed_date].[Month]&" "&Vehicles[for_disposed_date].[Year]

There I am just trying to look up this month, I have tried the following methods get errors.

 

CurrentPlannedDefleet = IF(Vehicles[Planned Defleet] = MONTH(now()),"Defleet", "No")
CurrentPlannedDefleet = IF(Vehicles[Planned Defleet] = MONTH(4),"Defleet", "No")

And have also tried:

CurrentPlannedDefleet = IF(Vehicles[Planned Defleet] = FORMAT("April",MONTH(4)),"Defleet", "No")

This one just returns "No" down the whole list when I definatley have some as "April 2017"

 

Hence my assumption it maybe to do with it being a calculated column.

 

Any pointers in the right direction would be appreciated.

 

Thanks

 

 

1 ACCEPTED SOLUTION

@xpfc

 

You can try Using

 

Column 2 = IF(MONTH(Vehicles[for_disposed_date])=MONTH(Today());"Yes";"No")

 

This Give you YES is both month are the same but not evalualing the year.

 

And this evaluate month and Year

 

Column 2 = if(MONTH([Vehicles[for_disposed_date])=MONTH(TODAY()) && YEAR(Vehicles[for_disposed_date])=YEAR(TODAY());"Yes";"No")

 




Lima - Peru

View solution in original post

3 REPLIES 3
Vvelarde
Community Champion
Community Champion

@xpfc

 

The result of this Column:

 

Planned Defleet = Vehicles[for_disposed_date].[Month]&" "&Vehicles[for_disposed_date].[Year]

in a date like 01/04/2017 is April 2017

 

And when you compare (Using IF) : 

CurrentPlannedDefleet = IF(Vehicles[Planned Defleet] = MONTH(now()),"Defleet", "No")

 

First you have a error because can't compare Text With Integers. 

 

And Also with the Format April 2017 is equal to 4 Result "No" or April 2017 is equal to April Result "No"

 

 

 




Lima - Peru

@xpfc

 

You can try Using

 

Column 2 = IF(MONTH(Vehicles[for_disposed_date])=MONTH(Today());"Yes";"No")

 

This Give you YES is both month are the same but not evalualing the year.

 

And this evaluate month and Year

 

Column 2 = if(MONTH([Vehicles[for_disposed_date])=MONTH(TODAY()) && YEAR(Vehicles[for_disposed_date])=YEAR(TODAY());"Yes";"No")

 




Lima - Peru
xpfc
Frequent Visitor

@Vvelarde

 

Thanks that works great.

 

I had also just rewritten it this way which also gets the required result.

CurrentPlannedDefleet = IF(Vehicles[for_disposed_date].[MonthNo] = MONTH(NOW()),"Defleet", "No")
CurrentPlannedDefleet = IF(MONTH(Vehicles[for_disposed_date]) = MONTH(TODAY()),IF(YEAR(Vehicles[for_disposed_date])=YEAR(TODAY()),"Defleet", "No"),"No")

 

Many Thanks

 

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.