Forum Discussion

mrg64's avatar
mrg64
Frequent Visitor
8 years ago
Solved

Calculating Days Between a Date and Today

I am trying to calculate the days between a date and today but I don't succed...

 

I've created a new column : 

DaysInWarehouse = DATEDIFF('caapps PackageHeader (2)'[WarehouseInDate];TODAY();DAY)

And I've got the following result:

WarehouseInDate   DaysInWarehouse

2018-04-04                    0

2018-04-03                  20

2018-03-29                 126

2018-03-28                 238

 

What am I doing wrong?

 

Thanks in advance

// magnus

  • Hi mrg64,

     

    I have made a test by entering the date and creating the Calculated Column with your dax expression in Power BI Desktop (Version: 2.56.5023.942 64-bit (March 2018)), everything works as expected.

     

     

    Please check if you have update to the latest Power BI Desktop and have a try.

     

    What data source have you connected with and  how to connected it?

     

    If you connected  by Direct Query, there should be some limitations.

     

    • Limitations in calculated columns: Calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions. Additionally, the DAX scalar functions (such as LEFT()) that are allowed, will be limited to those which can simply be pushed to the underlying source, hence will vary depending upon the exact capabilities of the source. Functions that are not supported will not be listed in autocomplete when authoring the DAX for a calculated column, and would result in an error if used.

     

    If you need additional help , please share your data structure.

     

    Best Regards,

    Cherry

4 Replies

  • v-piga-msft's avatar
    v-piga-msft
    Icon for Resident Rockstar rankResident Rockstar

    Hi mrg64,

     

    I have made a test by entering the date and creating the Calculated Column with your dax expression in Power BI Desktop (Version: 2.56.5023.942 64-bit (March 2018)), everything works as expected.

     

     

    Please check if you have update to the latest Power BI Desktop and have a try.

     

    What data source have you connected with and  how to connected it?

     

    If you connected  by Direct Query, there should be some limitations.

     

    • Limitations in calculated columns: Calculated columns are limited to being intra-row, as in, they can only refer to values of other columns of the same table, without the use of any aggregate functions. Additionally, the DAX scalar functions (such as LEFT()) that are allowed, will be limited to those which can simply be pushed to the underlying source, hence will vary depending upon the exact capabilities of the source. Functions that are not supported will not be listed in autocomplete when authoring the DAX for a calculated column, and would result in an error if used.

     

    If you need additional help , please share your data structure.

     

    Best Regards,

    Cherry

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hello I have followed the formula but the result shows negative 

       

  • mrg64's avatar
    mrg64
    Frequent Visitor

    I'am trying do calculate number of days between today and a date but I don't succed...

    I've created a column and defined number of days like this:

    DaysInWarehouse = DATEDIFF('caapps PackageHeader (2)'[WarehouseInDate];TODAY();DAY)

    I've got the following result:

    WarehouseInDate     DaysInWarehouse

    2018-04-04                        0

    2018-04-03                       20

    2018-03-29                      126

    2018-03-28                      238

    ..........

     

    What am I doing wrong?

     

    Thanks in advance

    // magnus