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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Power Query Custom Column with year and month

Hi to all, i try to add a custom column from my two date fields Start and End, but after, i got an error: 

Expression.Error: The value isn't a single-character string.
Details:
Value=202103

For create a custom column list i use this: 

{Date.ToText([Start_Date__c], "yyyyMM")..Date.ToText([End_Date__c], "yyyyMM")}

If i use {Date.Month([Start_Date__c])..Date.Month([End_Date__c])}

it gives me correct month values but, i need yearmonth format like yyyyMM

 

Can someone help me?

My every row, it's a week with start and end dates, if week only in one month, i expected to see like 202105, if week start from one month and end on another, i expected to see 2 values, 202105, 202106

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Solve my task with this code:

 

let 
Test = 
List.Distinct(List.Transform({[Start_Date__c],[End_Date__c]}, each Date.ToText(_, "yyyyMM")))
in
Test

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Solve my task with this code:

 

let 
Test = 
List.Distinct(List.Transform({[Start_Date__c],[End_Date__c]}, each Date.ToText(_, "yyyyMM")))
in
Test

 

Glad to your problem has been solved. Thank you for sharing.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.