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
Anonymous
Not applicable

Creating a Column with Number for Fiscal Month

I'm trying to add a column so I can do two things.

 

1st - Add column to get the number for each fiscal month

2nd - Add column to sort by fiscal month

 

I used the time function to create a column using:

 

= Table.AddColumn(#"Changed Type", "Number of Fiscal Month", each Date.Month([Document Date.Day]))

 

But this gives me calendar number (Eg. January = 1, December = 12)

 

I tried = Table.AddColumn(#"Changed Type", "Number of Fiscal Month", each Date.Month([Document Date.Day]+3))

 

Which resulted in January = 4 and December = 15, but I need January = 4, December = 3

 

Tried an If statement, 

 

IF( Date.Month([Document Date.Day]))<=9, Date.Month([Document Date.Day]))+3, Date.Month([Document Date.Day]))-3)

 

But that doesn't work.

 

I could do a replace value for each, but there must be a better way.

2 ACCEPTED SOLUTIONS
Greg_Deckler
Super User
Super User

@Anonymous I think you want:

IF( Date.Month([Document Date.Day]))<=9, Date.Month([Document Date.Day]))+3, Date.Month([Document Date.Day]))-9

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

v-jingzhang
Community Support
Community Support

Hi @Anonymous , try this: 

 

= Table.AddColumn(#"Changed Type", "Number of Fiscal Month", each if(Date.Month([Date])<=9) then Date.Month([Date])+3 else Date.Month([Date])-9, Int64.Type)

 

v-jingzhang_0-1600402636520.png

 

Best Regards,

Community Support Team _ Jing Zhang

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

View solution in original post

3 REPLIES 3
Anonymous
Not applicable

I think my problem was where I was building the formula.  I was working inside Transform Data and Add a Column.  For some reason it wouldn't let me add the formula there, but then I went into the Table View and Add a Column and it worked from there.

v-jingzhang
Community Support
Community Support

Hi @Anonymous , try this: 

 

= Table.AddColumn(#"Changed Type", "Number of Fiscal Month", each if(Date.Month([Date])<=9) then Date.Month([Date])+3 else Date.Month([Date])-9, Int64.Type)

 

v-jingzhang_0-1600402636520.png

 

Best Regards,

Community Support Team _ Jing Zhang

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

Greg_Deckler
Super User
Super User

@Anonymous I think you want:

IF( Date.Month([Document Date.Day]))<=9, Date.Month([Document Date.Day]))+3, Date.Month([Document Date.Day]))-9

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.