Forum Discussion

Dicken's avatar
Dicken
Post Prodigy
1 year ago
Solved

DAX DATATABLE

 

 

Hi, 
  I don't think the data type DATETIME availabel in DATATABLE works,  as in a date time should work as a date / time
but 

Dtable =
DATATABLE( "dDate" ,STRING,
{
    {"01/01/2020"}
} )
 
but to have an actual date ; 

 so something like 
Dtable =
DATATABLE( "dDate" ,DATETIME ,
{
   DATE(2020,1,1)+TIME(0,0,0)
} )  
but I cannot get anything to work, so is the DATETIME type usable. perhaps someone could look into this?

Richard. 
  • Deku's avatar
    Deku
    1 year ago

    Ran it on my machine. That function does not seem to like non hard coded values. This worked

     

    Dtable =
    DATATABLE( 
    "dDate", DATETIME ,
    {{"01/01/2020"}}
    )  

9 Replies

  • Deku's avatar
    Deku
    Super User
    This should work add a extra {} for the row
    Dtable =
    DATATABLE
    "dDate"DATETIME ,
    {{DATE(2020,1,1)}}
    )  
    • Dicken's avatar
      Dicken
      Post Prodigy

      I don't know if you got it to work but I get this ; 

      The tuple at index '1' from the table definition of the DATATABLE function does not have a constant expression in the column at index '1'

      • Deku's avatar
        Deku
        Super User

        Ran it on my machine. That function does not seem to like non hard coded values. This worked

         

        Dtable =
        DATATABLE( 
        "dDate", DATETIME ,
        {{"01/01/2020"}}
        )  

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi Dicken,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,

    Chaithra E.

    • Dicken's avatar
      Dicken
      Post Prodigy

      I have not had a response that works, regarding DATATABLE function, 
      so I don't think it is possible, I did use the 'enter data'  option, to give a  two date table for first and last. 
      Richard. 

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi Dicken ,

    Try this DAX expression: 

    Dtable =
    DATATABLE (
    "dDate", DATETIME,
    {
    { DATE(2020, 1, 1) + TIME(0, 0, 0) }
    }
    )

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi Dicken ,

     

    We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

    Regards,
    Chaithra.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi @Dicken,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,

    Chaithra E.