Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Help creating Invoice age in days

I have tried many of the suggestions in other posts but I think my problem is that I am connecting to a live SQL Server Analysis Services database. So I don't have the ablility (that I know of) to create a new Column or Table. I am trying to get the difference between Today() and Date Billed[Date Billed.Date].

 

Thank you

  • OK, lets try this.

    Age = 
    VAR InvoiceDateMax = MAX ( 'Table'[Date Billed.Date] )
    VAR InvoiceDate = IF ( InvoiceDateMax > TODAY(), TODAY(), InvoiceDateMax )
    RETURN DATEDIFF(InvoiceDate,today(),DAY)

    This will turn any invoice date that is after today into today.

10 Replies

  • Hello Anonymous 

    As long as you are displying the invoices so you only have a single billed date per line in your visual this will work.

    Age = 
    VAR InvoiceDate = SELECTEDVALUE ( 'Table'[Date Billed] )
    RETURN DATEDIFF(InvoiceDate,today(),DAY)
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you jdbuchanan71 

       

      Sorry, I'm pretty new to this. Can you explain SELECTEDVAULE? I'm not seeing that as a function, should what should go there?

      • jdbuchanan71's avatar
        jdbuchanan71
        Icon for Super User rankSuper User

        Anonymous 

        Can you share a sample of data from your table?  Paste it in a format that can be copied rather than a picture.