Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Having Trouble in Power Query

@ links to members, content

 

I am new to Power Query.  I tried to add this column  I am getting error message "Token Literal expected".  Here is my DAX in power query 

= Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] > Date.From(DateTime.LocalNow()) & if [Calibration Due] < Date.From(DateTime.LocalNow()+ 90 then "Due in 90 Days" else if [Calibration Due] > Date.From(DateTime.LocalNow()) then |
"In Calibration" else "OverDue")

 

My two condition is not being evaluated.  The results only returns "OverDue" 

  • Use this please

    = Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] <= Date.From(DateTime.LocalNow()) then "Overdue" else if [Calibration Due] <= Date.From(Date.AddDays(DateTime.LocalNow(),90)) then "Due in 90 Days"
    else "In Calibration")

     

5 Replies

  • mussaenda's avatar
    mussaenda
    Community Champion

    you think you should use "and" instead of "&"?

    or you should use "or" instead of "&".

     

    Try to play with these until you get your desired result.

     

    If you need more help,

    provide a sample data.

     

    Thanks

    • Anonymous's avatar
      Anonymous
      Not applicable

      the issue is the formula is not reading the first condition I do have some rows that meet that first condition.  I am having trouble adding 90 days to the Date.AddDays(DateTime.LocalNow(),90). I am getting error message "Token Literal Expected"

       

       

      = Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] > Date.From(DateTime.LocalNow()) and if [Calibration Due] < Date.AddDays(DateTime.LocalNow(),90) then "Due in 90 Days" else if [Calibration Due] > Date.From(DateTime.LocalNow()) then
      "In Calibration" else "OverDue")

      • Vijay_A_Verma's avatar
        Vijay_A_Verma
        Most Valuable Professional

        Use below formula

        = Table.AddColumn(#"Changed Type1", "CalDueFormat", each if [Calibration Due] <= Date.From(DateTime.LocalNow()) then "In Calibration" else if [Calibration Due] <= Date.From(Date.AddDays(DateTime.LocalNow(),90)) then "Due in 90 Days"
        else "Overdue")