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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
Jay2022
Helper III
Helper III

Greater than or less than dates = April 2023 etc

I want to add a new column to a table with the months defined from the dates column can't seem to get this working. Any help greatly appreciated. 

 

Dates = IF (

    [Date_Column] >= (2023, 04, 01)

    && [Date_column] <= (2023, 04, 30)  then "April 2023"

    else "")

 

Liekwise what would i have to do to do this for other months eg 

 

Dates = IF (

    [Date_Column] >= (2023, 04, 01)

    && [Date_column] <= (2023, 04, 30)  then "April 2023"

    else "", 

IF (

    [Date_Column] >= (2023, 05, 01)

    && [Date_column] <= (2023, 05, 31)  then "May 2023"

    else "", 

2 ACCEPTED SOLUTIONS
WinterMist
Impactful Individual
Impactful Individual

@Jay2022 

 

It seems unnecessary to create this IF/ELSE logic.

 

Instead, simply create the Year Month field in the CALENDAR table and use it as follows:

 

1) Create "Calendar" table using the following DAX.

 

WinterMist_0-1700602328046.png

 

2) Link 'Data' table to 'Calendar' table on [Date] columns.

 

WinterMist_1-1700602425563.png

 

WinterMist_2-1700602449844.png

 

3) Then just pull 'Calendar'[Year Month] onto the visual with whatever your 'Data' columns are...

 

WinterMist_3-1700602525599.png

 

 

Regards,

Nathan

 

P.S.  If you truly need to create a Calculated Column within another table, it can be done as follows:

 

WinterMist_0-1700603550026.png

 

 

View solution in original post

WinterMist
Impactful Individual
Impactful Individual

@Jay2022 

 

I just did a test and am actually surprised to find that Power BI handled NULL date values in my Fact 'Data' table without any issues.

 

Attached is the link to my PBIX for reference.

 

WinterMist_0-1700672206158.png

 

https://drive.google.com/drive/folders/13HqZmd_S7YEcTLWUr2txNN-7ysRug3ZX?usp=drive_link

 

Hopefully the PBIX is helpful to you.

 

Regards,

Nathan

 

WinterMist_1-1700672334530.png

 

WinterMist_2-1700672365724.png

 

View solution in original post

3 REPLIES 3
WinterMist
Impactful Individual
Impactful Individual

@Jay2022 

 

I just did a test and am actually surprised to find that Power BI handled NULL date values in my Fact 'Data' table without any issues.

 

Attached is the link to my PBIX for reference.

 

WinterMist_0-1700672206158.png

 

https://drive.google.com/drive/folders/13HqZmd_S7YEcTLWUr2txNN-7ysRug3ZX?usp=drive_link

 

Hopefully the PBIX is helpful to you.

 

Regards,

Nathan

 

WinterMist_1-1700672334530.png

 

WinterMist_2-1700672365724.png

 

WinterMist
Impactful Individual
Impactful Individual

@Jay2022 

 

It seems unnecessary to create this IF/ELSE logic.

 

Instead, simply create the Year Month field in the CALENDAR table and use it as follows:

 

1) Create "Calendar" table using the following DAX.

 

WinterMist_0-1700602328046.png

 

2) Link 'Data' table to 'Calendar' table on [Date] columns.

 

WinterMist_1-1700602425563.png

 

WinterMist_2-1700602449844.png

 

3) Then just pull 'Calendar'[Year Month] onto the visual with whatever your 'Data' columns are...

 

WinterMist_3-1700602525599.png

 

 

Regards,

Nathan

 

P.S.  If you truly need to create a Calculated Column within another table, it can be done as follows:

 

WinterMist_0-1700603550026.png

 

 

Thank you this is great help however when i try n connect this calendar table to my data i get this along with the error message 'Table content' and this under the calendar dax code. Can you please tell me what i'm doing wrong. I chan ged teh data column of my data to short date is that coorect. Also I ahve some Nulls in my date column will that be an issue ?

Jay2022_1-1700643070763.png

 

Thanks 

Jay2022_0-1700642985546.png

 

Helpful resources

Announcements
May PBI 25 Carousel

Power BI Monthly Update - May 2025

Check out the May 2025 Power BI update to learn about new features.

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

May 2025 Monthly Update

Fabric Community Update - May 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors