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
vjnvinod
Impactful Individual
Impactful Individual

Dax support

Hi team,

 

I have a  table (Master Session Tracker) where i have coloumn Event Date,  i want to create a new coloumn

wherein

if my coloumn event date is all previous months show me that as "YTD"

and  if my coloumn event date is current month show me that as "MMM"-YYYY"  for example Jun-2019

and if my coloumn event date is blank show me that as " Upcoming"

1 ACCEPTED SOLUTION

@vjnvinod 

 

Date(Year([Event Date]),Month([Event Date]),1) 

This is calculating the first day of the month of the EventDate in date format. For example, if the EventDate is 12-Jun-2019, then this formula is converting it to 1-Jun-2019

 

Date(Year(Today()),Month(Today()),1)

This formula is checking today's date and then calculating the first day of the month (same as logic above)

 

So essentially I am first converting the EventDate and Today's date to first of the month and then applied the condition you had mentioned.

 

FORMAT([Event Date],"MMM-YYYY"

This formula is converting the date into the required format.

 

Hope this answers your query.

 

Thanks,

Vivek

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

 

View solution in original post

9 REPLIES 9
vivran22
Community Champion
Community Champion

@vjnvinod 

 

Hi,

 

Please try this:

(This is considering that you are comparing the EventDate with current date, as it is not clear from your orignal query)

 

Column = If( [EventDate] = Blank()
,"Upcoming"
,If
(Date(Year([EventDate]),Month([EventDate]),1) < Date(Year(Today()),Month(Today()),1)
    , "YTD",If(Date(Year([EventDate]),Month([EventDate]),1) = Date(Year(Today()),Month(Today()),1),FORMAT(Table1[EventDate],"MMM-YYYY"
))))
 
Thanks,
Vivek
 
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
vjnvinod
Impactful Individual
Impactful Individual

@vivran22 

 

This is perfect & great, can you also explain me the working of below 2 conditions you have used?

 

If(Date(Year([Event Date]),Month([Event Date]),1) < Date(Year(Today()),Month(Today()),1), "YTD"
If(Date(Year([Event Date]),Month([Event Date]),1) = Date(Year(Today()),Month(Today()),1),FORMAT([Event Date],"MMM-YYYY"

@vjnvinod 

 

Date(Year([Event Date]),Month([Event Date]),1) 

This is calculating the first day of the month of the EventDate in date format. For example, if the EventDate is 12-Jun-2019, then this formula is converting it to 1-Jun-2019

 

Date(Year(Today()),Month(Today()),1)

This formula is checking today's date and then calculating the first day of the month (same as logic above)

 

So essentially I am first converting the EventDate and Today's date to first of the month and then applied the condition you had mentioned.

 

FORMAT([Event Date],"MMM-YYYY"

This formula is converting the date into the required format.

 

Hope this answers your query.

 

Thanks,

Vivek

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

 

hthota
Resolver III
Resolver III

if('Master Session Tracker'[Event Date]=BLANK(),Upcoming,if('Master Session Tracker'[Event Date]=curentmonth('Master Session Tracker'[Event Date]),format('Master Session Tracker'[Event Date],"MMM-YYYY",Year('Master Session Tracker'[Event Date]))

 

I hope it would help you.

 

Thanks & Regards,

Hemanth Thota.

if('Master Session Tracker'[Event Date]=BLANK(),"Upcoming",if('Master Session Tracker'[Event Date]=curentmonth('Master Session Tracker'[Event Date]),format('Master Session Tracker'[Event Date],"MMM-YYYY",Year('Master Session Tracker'[Event Date]))

 

I hope it would help you.

 

Thanks & Regards,

Hemanth Thota.

vjnvinod
Impactful Individual
Impactful Individual

@hthota 

 

Hi,

 

i am getting some error like below

 

newerror.PNG

Please provide any date field inside the previousmonth function. For example event date.

Anonymous
Not applicable

Any particular reason you want these as calculated columns vs. using measures?  

vjnvinod
Impactful Individual
Impactful Individual

@Anonymous 

i think measure can also help.

can you help me to create a measure for this issue?

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.