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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
podma
Regular Visitor

no valid "dates" in data model

Dear all,

 

I face the issue that there's no valid date in my data model.

 

Data source is Python and I'm not allowed to make any changes there.

The column that contains data information has the following structure: YYYYMM (e.g. 202412). However, this is not a valid date PowerBI can work with (e.g. I would like to work with the moving average function). Is there any possibility to convert the given text format in a valid date format? In Excel I could help myself with Right / Left functions (e.g. ="01"&"."&RIGHT(D4;2)&"."&LEFT(D4;4) to get 01.12.2024). But I have no idea what to do in PowerBI.

 

Many thanks for your help. Kind regards, Mathias

1 ACCEPTED SOLUTION
bhanu_gautam
Super User
Super User

@podma , Create a new calculated column using the below DAX

ValidDate =
VAR YearPart = LEFT('YourTable'[DateText], 4)
VAR MonthPart = RIGHT('YourTable'[DateText], 2)
RETURN
DATE(YearPart, MonthPart, 1)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






View solution in original post

3 REPLIES 3
podma
Regular Visitor

Many thanks

bhanu_gautam
Super User
Super User

@podma , Create a new calculated column using the below DAX

ValidDate =
VAR YearPart = LEFT('YourTable'[DateText], 4)
VAR MonthPart = RIGHT('YourTable'[DateText], 2)
RETURN
DATE(YearPart, MonthPart, 1)




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






your formula went perfectly well. As you can see in the following:

2024-07-11_16h40_38.png

 

 

 

 

 

2024-07-11_16h48_13.png2024-07-11_16h47_59.png

 

 

 

 

 

 

However, I got the following error message once I tried to realize a quick measure (a rolling average) based on the new column. Do you know why it's still not running?

2024-07-11_16h57_41.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

2024-07-11_16h18_06.png

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.