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

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

Reply
liuj3
New Member

how to convert data Q1, Q2, Q3 Q4 to numeric in powerQuery Editor

Hi everyone, i have difficulties about converting BIS data Q1, Q2, Q3, Q4 to mm/dd/yy format. the following code is used for get data from BIS website. the the second screen shot is data i got. is there anyways to convert time period data to format like 3rd photos? 

Capture.PNG

liuj3_0-1660596229057.png

liuj3_1-1660596411449.png

 

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

You can issue following statement where Source should be replaced with your previous step

Table.ReplaceValue(Source,each [#"Attribute:TIME_PERIOD"],each Date.EndOfMonth(#date(Number.From(Text.BeforeDelimiter([#"Attribute:TIME_PERIOD"],"-")),Number.From(Text.End([#"Attribute:TIME_PERIOD"],1))*3,1)),Replacer.ReplaceValue,{"Attribute:TIME_PERIOD"})

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQ0N9cNNFGK1QGzLXQDDaFsCwPdQCMo29JSN9AYzDYyMDAGq4kFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Attribute:TIME_PERIOD" = _t]),
    Custom = Table.ReplaceValue(Source,each [#"Attribute:TIME_PERIOD"],each Date.EndOfMonth(#date(Number.From(Text.BeforeDelimiter([#"Attribute:TIME_PERIOD"],"-")),Number.From(Text.End([#"Attribute:TIME_PERIOD"],1))*3,1)),Replacer.ReplaceValue,{"Attribute:TIME_PERIOD"}),
    #"Changed Type" = Table.TransformColumnTypes(Custom,{{"Attribute:TIME_PERIOD", type date}})
in
    #"Changed Type"

View solution in original post

4 REPLIES 4
liuj3
New Member

thank you , problem is solved 

wdx223_Daniel
Super User
Super User

NewStep=Table.TransformColumns(Source{1}[Table]{0}[#"Namespace:"]{0}[Series]{0}[Obs],{"Attribute:TIME_PERIOD",each Date.AddDays(Date.AddQuarters(Date.From(Text.BeforeDelimiter(_,"-")&"-1-1"),Number.From(Text.AfterDelimiter(_,"Q"))),-1)})

Vijay_A_Verma
Super User
Super User

You can issue following statement where Source should be replaced with your previous step

Table.ReplaceValue(Source,each [#"Attribute:TIME_PERIOD"],each Date.EndOfMonth(#date(Number.From(Text.BeforeDelimiter([#"Attribute:TIME_PERIOD"],"-")),Number.From(Text.End([#"Attribute:TIME_PERIOD"],1))*3,1)),Replacer.ReplaceValue,{"Attribute:TIME_PERIOD"})

See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQ0N9cNNFGK1QGzLXQDDaFsCwPdQCMo29JSN9AYzDYyMDAGq4kFAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Attribute:TIME_PERIOD" = _t]),
    Custom = Table.ReplaceValue(Source,each [#"Attribute:TIME_PERIOD"],each Date.EndOfMonth(#date(Number.From(Text.BeforeDelimiter([#"Attribute:TIME_PERIOD"],"-")),Number.From(Text.End([#"Attribute:TIME_PERIOD"],1))*3,1)),Replacer.ReplaceValue,{"Attribute:TIME_PERIOD"}),
    #"Changed Type" = Table.TransformColumnTypes(Custom,{{"Attribute:TIME_PERIOD", type date}})
in
    #"Changed Type"
jbwtp
Memorable Member
Memorable Member

Hi @liuj3,

 

The simpliest is the straightforward replacement.Something like this:

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMrQ0N9cNNFGK1QGzLXQDDZHYRkhsYyQ2UH0sAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Attribute: TIME_PERIOD" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Attribute: TIME_PERIOD", type text}}),
    #"Replaced Value" = Table.ReplaceValue(#"Changed Type","Q4","12-31",Replacer.ReplaceText,{"Attribute: TIME_PERIOD"}),
    #"Replaced Value1" = Table.ReplaceValue(#"Replaced Value","Q1","03-31",Replacer.ReplaceText,{"Attribute: TIME_PERIOD"}),
    #"Replaced Value2" = Table.ReplaceValue(#"Replaced Value1","Q2","06-30",Replacer.ReplaceText,{"Attribute: TIME_PERIOD"}),
    #"Replaced Value3" = Table.ReplaceValue(#"Replaced Value2","Q3","09-30",Replacer.ReplaceText,{"Attribute: TIME_PERIOD"}),
    #"Parsed Date" = Table.TransformColumns(#"Replaced Value3",{{"Attribute: TIME_PERIOD", each Date.From(DateTimeZone.From(_)), type date}})
in
    #"Parsed Date"

 

 

 

Alternatively, you can create a table of dates to quarters. Spit the time period column to separate out Qx andthen merge using the dates to quarters table.

 

Kind regards,

John

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.

Top Kudoed Authors