cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
pcal Frequent Visitor
Frequent Visitor

Data function in power BI help

Hi There 

 

Can someone help me with my data formula: 

Trying to convert date (month-year) to #data(year, month, day)

#date((right([Attribute],4), (left([Attribute],search([Attribute], "-")-1). 1)

 

Thank you

1 ACCEPTED SOLUTION

Accepted Solutions
Community Support Team
Community Support Team

Re: Data function in power BI help

Hi @pcal ,

 

You could split the original date column first. Then, new a custom column via #date function.

= Table.AddColumn(#"Changed Type", "New date column", each #date([Date.2],[Date.1],1))

1.PNG2.PNG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ1MjC0VIrVATKNoOxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Date", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Date.1", "Date.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Date.1", Int64.Type}, {"Date.2", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "New date column", each #date([Date.2],[Date.1],1))
in
    #"Added Custom"

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
3 REPLIES 3
Super User
Super User

Re: Data function in power BI help

What does your original data look like? Is it like:

 

1/2019

 

or 

 

01/2019

 


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!


pcal Frequent Visitor
Frequent Visitor

Re: Data function in power BI help

Hi Greg

 

The date is currently 

1-2019 or 12-2019

 

Thanks

 

Community Support Team
Community Support Team

Re: Data function in power BI help

Hi @pcal ,

 

You could split the original date column first. Then, new a custom column via #date function.

= Table.AddColumn(#"Changed Type", "New date column", each #date([Date.2],[Date.1],1))

1.PNG2.PNG

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMtQ1MjC0VIrVATKNoOxYAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Date = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Date", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Date.1", "Date.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Date.1", Int64.Type}, {"Date.2", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "New date column", each #date([Date.2],[Date.1],1))
in
    #"Added Custom"

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.