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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors