Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
I am creating a condiitonal column and want the output to be date, i was using this #date(2023, 9, 1) as syntax in the output column and formatted the new column as date, for some reason the column in throwing an error. What could be wrong.
Solved! Go to Solution.
Thanks for the additional info. You can do something like this...
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nL0U4rViVZyc3UC076OQWDaMSAIyo8E016hflDaByIf6g6mg10DwLS/cwiY9vMPA9Murs5KsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}}),
DateFromMonth = Table.AddColumn(#"Changed Type", "Date",
let
strMonths = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}
in
each
try
let intMonth = List.PositionOf ( strMonths, [Month] ) + 1 in
Date.ToText ( #date(2023,intMonth,1), "dd-MM-yyyy" )
otherwise null, type text
)
in
DateFromMonth
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User
@Sudi Have you had a chance to look at the solution provided? Please consider clicking Accept as Solution if this answered your question or solved your problem. Thanks!
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User
Thank you Jen, Posting more details if that helps
Thanks for the additional info. You can do something like this...
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8nL0U4rViVZyc3UC076OQWDaMSAIyo8E016hflDaByIf6g6mg10DwLS/cwiY9vMPA9Murs5KsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Month = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Month", type text}}),
DateFromMonth = Table.AddColumn(#"Changed Type", "Date",
let
strMonths = {"JAN", "FEB", "MAR", "APR", "MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC"}
in
each
try
let intMonth = List.PositionOf ( strMonths, [Month] ) + 1 in
Date.ToText ( #date(2023,intMonth,1), "dd-MM-yyyy" )
otherwise null, type text
)
in
DateFromMonth
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User
Hello - it's difficult to say what's wrong without seeing the error message being thrown or the condition and data. That being said, I would guess that the problem may be the data type like one or more of the below reasons:
If you need further assistance, please post some sample data along with your script and the error message being generated.
If this post helps to answer your questions, please consider marking it as a solution so others can find it more quickly when faced with a similar challenge.
Proud to be a Microsoft Fabric Super User