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

Bi-Monthly Reporting - how to set-up calendar?

Hi everyone!

 

I have a data that comes bi-monthly: (DJ is December-January; FM - February-March, etc.). I was wondering how can I setup a calendar that way so the data type would be seen for Power BI as date. Here's the table:

 

bimonthly.jpg

 

Thank you in advance!

 

Best,

Zhibek

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

HI @Anonymous,

You can extract original table date fields to create a new calendar table with custom column 'bi-month', then use it to link to the raw table date field. After these steps, you can mapping your records to the real calendar date to calculate and analysis

Calendar =
VAR yearlist =
    SELECTCOLUMNS ( 'Table', "Year", RIGHT ( [Date], 4 ) )
RETURN
    ADDCOLUMNS (
        CALENDAR (
            DATE ( MINX ( yearlist, [Year] ), 1, 1 ),
            DATE ( MAXX ( yearlist, [Year] ), 12, 31 )
        ),
        "Bi-Month",
        VAR curr = [Date]
        VAR _month =
            IF (
                MOD ( MONTH ( curr ), 2 ) = 0,
                LEFT ( FORMAT ( curr, "MMM" ), 1 )
                    & LEFT ( FORMAT ( DATE ( YEAR ( curr ), MONTH ( curr ) + 1, 1 ), "MMM" ), 1 ),
                LEFT ( FORMAT ( DATE ( YEAR ( curr ), MONTH ( curr ) - 1, 1 ), "MMM" ), 1 )
                    & LEFT ( FORMAT ( curr, "MMM" ), 1 )
            )
        VAR _year =
            IF ( MONTH ( curr ) < 11, YEAR ( curr ), YEAR ( curr ) + 1 )
        RETURN
            _month & " " & _year
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

3 REPLIES 3
v-shex-msft
Community Support
Community Support

HI @Anonymous,

You can extract original table date fields to create a new calendar table with custom column 'bi-month', then use it to link to the raw table date field. After these steps, you can mapping your records to the real calendar date to calculate and analysis

Calendar =
VAR yearlist =
    SELECTCOLUMNS ( 'Table', "Year", RIGHT ( [Date], 4 ) )
RETURN
    ADDCOLUMNS (
        CALENDAR (
            DATE ( MINX ( yearlist, [Year] ), 1, 1 ),
            DATE ( MAXX ( yearlist, [Year] ), 12, 31 )
        ),
        "Bi-Month",
        VAR curr = [Date]
        VAR _month =
            IF (
                MOD ( MONTH ( curr ), 2 ) = 0,
                LEFT ( FORMAT ( curr, "MMM" ), 1 )
                    & LEFT ( FORMAT ( DATE ( YEAR ( curr ), MONTH ( curr ) + 1, 1 ), "MMM" ), 1 ),
                LEFT ( FORMAT ( DATE ( YEAR ( curr ), MONTH ( curr ) - 1, 1 ), "MMM" ), 1 )
                    & LEFT ( FORMAT ( curr, "MMM" ), 1 )
            )
        VAR _year =
            IF ( MONTH ( curr ) < 11, YEAR ( curr ), YEAR ( curr ) + 1 )
        RETURN
            _month & " " & _year
    )

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Greg_Deckler
Super User
Super User

Probably going to be a SWITCH statement like:

 

Column = 

  SWITCH(TRUE(),

    LEFT([Date],1) = "D",DATE(RIGHT([Date],4),12,1),

   ...

  )


@ 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

Dear Greg @Greg_Deckler ,

 

Thank you for such a quick response!

I am a beginner and didn't quite get that... could you please briefly explain what "D", 4),12,1) - mean in the formula? And should I add it as a custom column? 

For now my calendar looks like that: 

calendar.jpg

 

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.