cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Upcoming Events

Upcoming Events

Wondering what events you could join or have an event to promote yourself? Check out our Upcoming Events.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Top Solution Authors
Top Kudoed Authors