cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

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

Accepted Solutions
Highlighted
Community Support
Community Support

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

HI @zhibekyer,

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 it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
Highlighted
Super User IV
Super User IV

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

Probably going to be a SWITCH statement like:

 

Column = 

  SWITCH(TRUE(),

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

   ...

  )


---------------------------------------

Putting square pegs in round holes since 1972.

I have a NEW book! 
DAX Cookbook from Packt
Over 120 DAX Recipes!




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Highlighted
Frequent Visitor

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

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!

Highlighted
Community Support
Community Support

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

HI @zhibekyer,

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 it as the solution to help the other members find it more quickly.

View solution in original post

Helpful resources

Announcements
May 2020 Community Highlights

May 2020 Community Highlights

It’s time for another PBI Community recap!

Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Top Solution Authors