Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Adding days since from a SQLdb Report

Good Morning PowerBI!

 

I have a report that queries a sql db directly and noticed if I added tables, it changes the type of report which will download all the tables which takes a while.

 

I was wondering if I can add a measure that wouldn't do this, or if changing the type of query was the only option.

I'm see there is a column for date opened and date closed, and the dates are like such below -

 

2/10/2015 12:56:02 AM

 

I was hoping to calculate, days since opened, days to close, would any kind souls be able to answer the question about the direct query and maybe a sample calculation?

 

Thanks!

4 Replies

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

    Hi Anonymous ,

     

    If you don't want to load all the data every time you refresh, you can use incremental refresh.

    Incremental refresh in Power BI 

     

    Or you can add sql statement.

    We mainly use M language to deal with the problem of connecting data sources. DAX is generally used to model data.

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

     

     

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

    Hi Anonymous ,

     

    Has your problem been solved?

     

    Best regards,
    Lionel Chen

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • Anonymous's avatar
      Anonymous
      Not applicable

      v-lionel-msft Hi Lionel,

       

      I actually figured it out. On a direct query database, if you use a measurement it will achieve what you need and in my case, it was days from a certain field.

       

      Difference = DATEDIFF( *Table*[*Field*], TODAY(), DAY)
       
      adding this measurement allowed me to calculate the days passed from *field* (this was a date entered) without changing it from direct query.
      I added this for a group of folks who wanted to see immediate changes (refresh button mashers).
       
      Hopefully this may help other folks dealing with refresh mashers as well.