Forum Discussion

andi2333's avatar
andi2333
Helper I
1 year ago
Solved

Cannot convert the value #date to type List

Hello,

I have a simple question for a simple query.

I would like to introduce a custom column B which shows "true" or "false" if the date in column A is the maximal value (aka newest date) available.

 

My query: 

if List.Max([Real Date])=[Real Date] then "TRUE" else "FALSE"

Howver, PQ tells me that "We cannot convert the value #date(2024, 1, 1) to type List.".

Still a bit new to PQ, but I figure this should be super simple to solve?

 

Thanks in advance.

  • Hi andi2333 ,

     

    You're trying to evaluate the current row in a list context as you're applying your calculation to the current table (query step).

    Try moving the max evaluation to the previous table/query step:

     

    if List.Max([Real Date])=[Real Date] then "TRUE" else "FALSE"
    
    // goes to:
    
    if List.Max( PreviousStepName[Real Date]) = [Real Date] then "TRUE" else "FALSE"

     

    You can actually simplify further by just using a logical expression:

     

    List.Max( PreviousStepName[Real Date]) = [Real Date]

     

    *BUMP* Repost as original apparently wasn't showing up.

     

    Pete

  • in the case of using 

    if List.Max([Real Date])=[Real Date] then "TRUE" else "FALSE"

    the value of [Real Date] is not a list and is just a value in type date, if you want to refer to the whole column, you have to mention the name of previous step befor the name of column,

     

    if the previous step is Source, rewrite the formula as 

    List.Max(Source[Real Date])=[Real Date]

2 Replies

  • in the case of using 

    if List.Max([Real Date])=[Real Date] then "TRUE" else "FALSE"

    the value of [Real Date] is not a list and is just a value in type date, if you want to refer to the whole column, you have to mention the name of previous step befor the name of column,

     

    if the previous step is Source, rewrite the formula as 

    List.Max(Source[Real Date])=[Real Date]

  • Hi andi2333 ,

     

    You're trying to evaluate the current row in a list context as you're applying your calculation to the current table (query step).

    Try moving the max evaluation to the previous table/query step:

     

    if List.Max([Real Date])=[Real Date] then "TRUE" else "FALSE"
    
    // goes to:
    
    if List.Max( PreviousStepName[Real Date]) = [Real Date] then "TRUE" else "FALSE"

     

    You can actually simplify further by just using a logical expression:

     

    List.Max( PreviousStepName[Real Date]) = [Real Date]

     

    *BUMP* Repost as original apparently wasn't showing up.

     

    Pete