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

How to calculate 'Commercial Month' - a month which begins on the 14th

Hi everyone, 

 

I was wondering if there is a way to create a calculated column for a 'Commercial Month', that being, I need to work out sales figures from 14th-13th of each 'Commercial Month'. 

 

For example, lets say the first commercial month begins 14/02/2018-13/03/2018, which is February. The commercial month of March would be 14/03/2018-13/04/2018 etc etc. Is there a way (ideally without having to write lots of DAX code as i'm still very new to PowerBI and DAX) which this can be calculated?

 

Thanks in advance

1 ACCEPTED SOLUTION

Hi @Anonymous,

 

You could create a calucated column in your calendar table with the formula below.

 

Column =
VAR t =
    IF (
        DAY ( [Date] ) >= 14,
        MONTH ( [Date] ),
        IF (
            DAY ( [Date] ) <= 13,
            IF ( MONTH ( [Date] ) <> 1, MONTH ( [Date] ) - 1, 12 )
        )
    )
RETURN
    FORMAT ( DATEVALUE ( t & "-" & "2018" ), "mmmm" )

Here is the output.

 

Capture.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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

4 REPLIES 4
Greg_Deckler
Super User
Super User

Do you have a Calendar table?


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

Yes I do have a calendar table. 

Hi @Anonymous,

 

You could create a calucated column in your calendar table with the formula below.

 

Column =
VAR t =
    IF (
        DAY ( [Date] ) >= 14,
        MONTH ( [Date] ),
        IF (
            DAY ( [Date] ) <= 13,
            IF ( MONTH ( [Date] ) <> 1, MONTH ( [Date] ) - 1, 12 )
        )
    )
RETURN
    FORMAT ( DATEVALUE ( t & "-" & "2018" ), "mmmm" )

Here is the output.

 

Capture.PNG

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

That worked! Thank you very much for your help Cherry!

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.