Forum Discussion

noah44's avatar
noah44
Helper I
3 years ago

Alternative for calculated column in Direct Query

Hi,

is there a way to create a calculated column with Direct Query that gives me the same output as this one?

 

Max Date = CALCULATE( MAX( Table1[DateColumn] ), ALLEXCEPT( Table1, Table1[UserID] ) )

 

 

Regards 

Noah

4 Replies

  • v-yalanwu-msft's avatar
    v-yalanwu-msft
    Community Support

    Hi, noah44 ;

    First of all, in the Directquery mode, the computed column cannot be created, only in import.
    Using DirectQuery in Power BI - Power BI | Microsoft Learn



    Second , If the above formula changes to a column, you can use the following two ways

    Max Date =
    CALCULATE ( MAX ( Table1[DateColumn] ), ALLEXCEPT ( Table1, Table1[UserID] ) )
    
    Max Date =
    CALCULATE (
        MAX ( Table1[DateColumn] ),
        FILTER ( Table1, [UserID] = EARLIER ( Table1[UserID] ) )
    )
    

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

    • noah44's avatar
      noah44
      Helper I

      Hi v-yalanwu-msft,

       

      Thank you for your answer!

      I understand that the above formula does not Work in Direct Query mode.

      So the two ways shown in your post won't work either because of CALCULATE() not being available in DQ-Mode.

       

      Is there no alternative way of reaching the same result, within the DQ-Mode restrictions?

      Regards
      Noah

      • v-yalanwu-msft's avatar
        v-yalanwu-msft
        Community Support

        Hi, noah44 ;

        Because in DQ can't create column,so you could create a measure by dax


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