Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
kivancc94
Helper I
Helper I

Creating Calendar Column with Date Condition

Hi

 

I would be happy if you could help me. I have also used measure to solve that but failed.

kivancc94_0-1691844043709.png


Problem : If today is the first day of current month , for example ( 01 August 2023 ) then start the calendar from the beginning of previous month till the end of previous month --> 01 July 2023 .... till 31 July 2023. 

Else start the calendar from beginning of current month ( 01 August 2023 ) till the end of current month ( 31 August 2023)


Column =
IF(
     TODAY() = DATE(YEAR(TODAY()),MONTH(TODAY()),1), // If today is the first day of current month ( 01 / Month / Year )

CALENDAR(
    DATE(
        YEAR(TODAY()),
        MONTH(TODAY()-1),
        1),   // Beginning of Previous Month

    EOMONTH(
        TODAY(),-1)), // End of Previous Month

// ELSE

CALENDAR(
    DATE(
        YEAR(TODAY()),
        MONTH(TODAY()),
        1),   // Beginning of this month

    EOMONTH(
        TODAY(),0))) // End of this month

 

 


Thanks in advance.

Regards

1 ACCEPTED SOLUTION
mickey64
Super User
Super User

I made a calendar table.
 
Column = CALENDAR(
        IF(DAY(TODAY()) = 1,
            DATE(YEAR(TODAY()), MONTH(TODAY())-11),
            DATE(YEAR(TODAY()), MONTH(TODAY()), 1)),
        IF(DAY(TODAY()) = 1, 
            EOMONTH(TODAY(),-1),
            EOMONTH(TODAY(),0)))

View solution in original post

5 REPLIES 5
mickey64
Super User
Super User

I made a calendar table.
 
Column = CALENDAR(
        IF(DAY(TODAY()) = 1,
            DATE(YEAR(TODAY()), MONTH(TODAY())-11),
            DATE(YEAR(TODAY()), MONTH(TODAY()), 1)),
        IF(DAY(TODAY()) = 1, 
            EOMONTH(TODAY(),-1),
            EOMONTH(TODAY(),0)))

Worked ! Thanks a lot.

mickey64
Super User
Super User

Column = CALENDAR(
    IF(DAY(TODAY()) = 1,
        DATE(
            YEAR(TODAY()),
            MONTH(TODAY())-1,
            1),
        DATE(
            YEAR(TODAY()),
            MONTH(TODAY()),
            1)
    ),
    IF(DAY(TODAY()) = 1,
        EOMONTH(
            TODAY(),-1),
        EOMONTH(
            TODAY(),0)))
jdbuchanan71
Super User
Super User

The CALENDAR function returns a table, so I don't think that is what you are wanting.  Is this what you are looking for?

 

Column =
VAR _Today = TODAY()
RETURN
    IF (
        DAY ( _Today ) = 1,
        EOMONTH ( _Today, -2 ) + 1 & " - " & EOMONTH ( _Today, -1 ),
        EOMONTH ( _Today, -1 ) + 1 & " - " & EOMONTH ( _Today, -0 )
    )

 

It's not really clear to me what is the exact string you are wanting to see in that colmn today, Aug 12th and what would you want to see when TODAY() = Sept 1st?

 

What do you want to see on the rows for dates 3 months ago?

 

As an example.

If today is 01.08.2023 ( first day of current month)
  I would like to have calendar table between 01.07.2023 - 31.07.2023 

else ( today is <> 01.08.2023 )

I would like to have calendar table between 01.08.2023 - 31.08.2023 




Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.