cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Tlotly
Helper II
Helper II

Create a mmm-yyyy column

Dear community

 

Is it possible for a YearMont column to be a date format? So basically I'm trying to create a financial yearmonth field from the calendar but I'm not getting it right. It creates successfully as below but I'm struggling to convert it to a date format so that I create the column with this format  "mmm-yyyy", e.g. Jan - 2020.

Tlotly_0-1625041158818.png

 

 

Below is the DAX I used to create the column,  I even used the Format function and I'm still not getting the results I want. I've tried changing the column to Text then Date, it gives me an error. Since this is from a calendar created within the report, I can't use Transform data option. 

 

Please assist.

FinYearMonth = VAR FiscalStartMonth = 7
                            VAR FinYearMonth =
                       IF ( MONTH ( [Date] ) > ( FiscalStartMonth - 1 ),
                         ((YEAR ( [Date] ) * 100)+1) + MONTH([Date]),
                           ((YEAR ( [Date] ) * 100)) + MONTH([Date]))
)
RETURN
FinYearMonth

Thank you

Matlotlo

 

1 ACCEPTED SOLUTION
Kumail
Super User
Super User

@Tlotly 

 

If I understood your logic correctly, then this should help

 

 

FinYearMonth = 
VAR FiscalStartMonth = 7
VAR FinYearMonth = If( MONTH([Date]) > (FiscalStartMonth - 1),
                        DATE((YEAR([Date])+1),MONTH([Date]),DAY([Date])),
                        DATE(YEAR([Date]),MONTH([Date]),DAY([Date])))
RETURN
FORMAT(FinYearMonth, "mmmm-yyyy")

 

 

 

I hope this helps.

 

Regards

Kumail Raza

View solution in original post

6 REPLIES 6
Kumail
Super User
Super User

@Tlotly 

 

If I understood your logic correctly, then this should help

 

 

FinYearMonth = 
VAR FiscalStartMonth = 7
VAR FinYearMonth = If( MONTH([Date]) > (FiscalStartMonth - 1),
                        DATE((YEAR([Date])+1),MONTH([Date]),DAY([Date])),
                        DATE(YEAR([Date]),MONTH([Date]),DAY([Date])))
RETURN
FORMAT(FinYearMonth, "mmmm-yyyy")

 

 

 

I hope this helps.

 

Regards

Kumail Raza

@Kumail  thank you very much. Worked liked a charm

@Tlotly 

You're Welcome!!

 

If you liked the solution, dont forget to Thumbs up

 

Thanks,

Kumail Raza

 

Kumail
Super User
Super User

Hello @Tlotly 

 

If you could send sample .pbix that demonstrate what you are looking to get. It would really help providing you a quick solution.

 

Regards
Kumail Raza

amitchandak
Super User
Super User

@Tlotly , if you have date , you can do it using format

 

format([Date], "mmm -yyyy")

Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
Proud to be a Super User!
!! Subscribe to my youtube Channel !!

@amitchandak  the only date I have is a calendar date, hence I'm trying to create Fiscal date but with mmm-yyyy format. My fiscal dates are from Jul - Jun. 

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it Out!

Join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors