I'm trying to create a custom column in my Power Query Editor using the below code however whenever I add the last line of the code I get the Expression.SyntaxError: Token 'else' expected. message.
Can someone help correct the Syntax error I've created here?
= Table.AddColumn(#"Renamed Columns", "SkillCo Validity", each if [Expiry Date] = null then "Valid" else /* If no expiry date given, then Valid */
/* If the comp is live and expires in the next 30d, then Due (30d)*/
if DateTime.IsInNextNHours([Expiry Date], 720) then "Due (30d)" else
/* If the comp is live and expires in the next 60d, then Due (60d)*/
if DateTime.IsInNextNHours([Expiry Date], 1440) then "Due (60d)" else
/* If the comp is shelved and expires in the next 60d, then Dropping */
if DateTime.IsInNextNHours([Expiry Date], 1440) then "Dropping" else
/* If the expiry date is in the future, then Valid */
if [Expiry Date] > DateTime.Date(DateTime.LocalNow()) then "Valid" else
/* If the comp has been archived, then Dropped, else Expired */
if [Expiry Date] = "Yes" then "Dropped" else "Expired")
/* If the comp has No Expiry then show blank */
(if [Expiry Date] = "No Expiry" then "" )
The syntax is if .. then ... else
reverse your last two lines to do that
.... then "Valid" else
if [Expiry Date] = "No Expiry" then "" else
if [Expiry Date] = "Yes" then "Dropped" else "Expired"