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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Jay2022
Helper II
Helper II

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.